#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define str string
#define pb push_back
#define ins insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pii pair<int, int>
#define ff first
#define ss second
#define ld long double
#define sz(a) (int)a.size()
#define int ll

mt19937 rnd(1488);

vector<vector<int>> gr;
vector<int> s;
int t = 0;
set<pii> tec;
vector<int> dp;
vector<int> cnt;
vector<int> ans;
set<int> tec2;

void dfs(int v){
    cnt[v] = 1;
    ans[v] = dp[v] - *tec2.rbegin();
    for (auto u:gr[v]){
        tec.ins({s[u], u});
    }
    if (sz(tec)){
        int u = (*tec.rbegin()).ss;
        tec.erase(*tec.rbegin());
        dp[u] = dp[v] + 1;
        tec2.ins(cnt[v]);
        dfs(u);
        cnt[v] += cnt[u];
        tec2.ins(cnt[v]);
    }
}

void solve(){
    int n, q;
    cin >> n >> q;
    gr.resize(n);
    for (int i = 1; i < n; i++){
        int pr;
        cin >> pr;
        --pr;
        gr[pr].pb(i);
    }
    s.resize(n);
    for (int i = 0; i < n; i++){
        cin >> s[i];
    }
    dp.resize(n);
    cnt.resize(n);
    ans.resize(n);
    tec2.ins(0);
    dfs(0);
    while (q--){
        int v;
        cin >> v;
        cout << ans[--v] << " ";
    }
}

int32_t main(){
    cin.tie(0)->ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif // LOCAL
    int _ = 1;
    //cin >> _;
    while (_--){
        solve();
    }
}
