#pragma GCC optimize("arch=skylake")
#pragma GCC optimize("Ofast,inline")

#include <bits/stdc++.h>

using namespace std;

//#define int int64_t
#define fi first
#define se second
mt19937 gen(time(0));

const int N = 3e5 + 12;
vector <int> g[N];
int a[N], ans[N], pr[N];

pair <pair<int,int>,pair<int,int>> res[N];

int calc(int v) {
    int ans = 0;
    while(v != 1) {
        int u = pr[v];
        if(res[u].fi.se == v) {
            ans = max(ans, res[u].se.fi);
        } else {
            ans = max(ans, res[u].fi.fi);
        }
        v = u;
    }
    return ans;
}
int cnt[N];
void upd(int v) {
    while(v != 1) {
        cnt[v]++;
        int u = pr[v];
        pair <int,int> cur = {cnt[v], v};
        if(res[u].fi.se == v) {
            res[u].fi = cur;
        } else if(res[u].se.se == v) {
            res[u].se = cur;
        } else {
            if(cur > res[u].fi) {
                res[u].se = res[u].fi;
                res[u].fi = cur;
            } else if(cur > res[u].se) {
                res[u].se = cur;
            }
        }
        if(res[u].se > res[u].fi)
            swap(res[u].fi, res[u].se);
        v = u;
    }
    return;
}

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, qq;
    cin >> n >> qq;
    for(int i = 2; i <= n; ++i) {
        cin >> pr[i];
        g[pr[i]].push_back(i);
    }
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    set <pair<int,int>> st;
    for(auto to : g[1]) {
        st.insert({a[to], to});
    }
    int it = 1;
    while(st.size()) {
        pair<int,int> mx = *st.rbegin();
        ans[mx.se] = it - calc(mx.se);
        it++;
        upd(mx.se);
        st.erase(mx);
        for(auto to : g[mx.se]) {
            st.insert({a[to], to});
        }
    }
    while(qq--) {
        int v;
        cin >> v;
        cout << ans[v] << ' ';
    }
    return 0;
}
