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

vector<int> s, p, a, ans;
vector<vector<int>> g;

void solve() {
    int n, q, res = 0;
    cin >> n >> q;
    s.assign(n + 1, 0);
    p.assign(n + 1, 0);
    a.assign(n + 1, 0);
    g.assign(n + 1, {});
    ans.assign(n + 1, 0);
    for (int v = 2; v <= n; v++) {
        cin >> p[v];
        g[p[v]].push_back(v);
    }
    for (int i = 1; i <= n; i++) cin >> s[i];
    set<array<int, 2>> b;
    b.insert({s[1], 1});
    while (!b.empty()) {
        array<int, 2> ar = *b.rbegin();
        b.erase(ar);
        int v = ar[1], v2 = v, v3;
        ans[v] = res++;
        while (v2 != 0) {
            a[v2]++;
            v2 = p[v2];
        }
        v2 = v;
        v3 = p[v2];
        int mx = 0;
        while (v3 != 0) {
            for (auto u: g[v3]) {
                if (u == v2) continue;
                mx = max(mx, a[u]);
            }
            v2 = v3;
            v3 = p[v3];
        }
        ans[v] -= mx;
        for (auto u: g[v]) {
            b.insert({s[u], u});
        }
    }
    while (q--) {
        int v;
        cin >> v;
        cout << ans[v] << ' ';
    }
}

int32_t main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    solve();
}
