#include <bits/stdc++.h>
using namespace std;
#define int long long


main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector < vector < int > > G(n);
    vector < int > p(n);
    for (int i = 1; i < n; i++) {
        cin >> p[i]; p[i]--;
        G[p[i]].push_back(i);
    }
    vector < int > s(n);
    for (int i = 0; i < n; i++) cin >> s[i];

    int T = 0;
    vector < int > tin(n), ans(n);
    priority_queue < pair < int , int > > pq;
    pq.push({s[0], 0});
    vector < int > A;
    while (!pq.empty()) {
        int v = pq.top().second; pq.pop();
        tin[v] = T++;
        A.push_back(v);
        for (auto u : G[v]) pq.push({s[u], u});
    }
    multiset < int > se;
    for (int i = 0; i < n; i++) se.insert(0);
    vector < int > cnt(n);
    for (auto v : A) {
        int i = v;
        while (i != 0) {
            se.erase(se.find(cnt[i]));
            cnt[i]++;
            i = p[i];
        }
        int mx = *se.rbegin();
        ans[v] = tin[v] - mx;

        i = v;
        while (i != 0) {
            se.insert(cnt[i]);
            i = p[i];
        }
    }

    while (q--) {
        int v;
        cin >> v; v--;
        cout << ans[v] << ' ';
    }
    cout << '\n';
}
