#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;
vector<int> tin;
vector<int> tout;
int t = 0;
set<pii> tec;
vector<int> dp;
vector<int> dp2;
vector<int> cv;

void dfs2(int v, int col){
    tin[v] = t++;
    if (v){
        cv[v] = col;
    }
    for (auto u:gr[v]){
        col += (v == 0);
        dfs2(u, col);
    }
    tout[v] = t;
}

void dfs(int v){
    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;
        dp2[dp[u]] = u;
        dfs(u);
    }
}

void solve(){
    int n, q;
    cin >> n >> q;
    gr.resize(n);
    cv.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];
    }
    tin.resize(n);
    tout.resize(n);
    dp.resize(n);
    dp2.resize(n);
    dfs2(0, -1);
    dfs(0);
    vector<array<int, 3>> z(q);
    for (int i = 0; i < q; i++){
        int v;
        cin >> v;
        --v;
        z[i] = {dp[v], v, i};
    }
    sort(all(z));
    set<pii> st;
    vector<int> cnt(n);
    for (int i = 0; i < n; i++){
        st.ins({cnt[i], i});
    }
    int j = 0;
    vector<int> ans(q);
    for (auto [i, v, ind]:z){
        while (j < i){
            int u = dp2[j++];
            if (u){
                st.erase({cnt[cv[u]], cv[u]});
                cnt[cv[u]]++;
                st.ins({cnt[cv[u]], cv[u]});
            }
        }
        ans[ind] = i;
        if (sz(st) == 1) continue;
        if ((*st.rbegin()).ss == cv[v]){
            ans[ind] -= (*(--st.rbegin())).ff;
        }
        else{
            ans[ind] -= (*st.rbegin()).ff;
        }
    }
    for (auto i:ans){
        cout << i << " ";
    }
}

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();
    }
}
