#include <bits/stdc++.h>

using namespace std;
const int MAXN = 3e5 + 1;
vector<int> g[MAXN];
int parent[MAXN], s[MAXN], ans[MAXN], val[MAXN];

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

    int n, q;
    cin >> n >> q;
    for (int i = 2; i <= n; i++) {
        int p;
        cin >> p;
        parent[i] = p;
        g[p].push_back(i);
    }
    for (int i = 1; i <= n; i++) {
        ans[i] = MAXN;
        cin >> s[i];
    }
    for (int i = 1; i <= n; i++) {
        sort(g[i].begin(), g[i].end(), [&](int a, int b) {
            return s[a] < s[b];
        });
    }

    int timer = 0;
    set<pair<int, int>, greater<>> rm = {{0, 1}};
    multiset<int> vals;
    while (!rm.empty()) {
        auto [_, u] = *rm.begin();
        rm.erase(rm.begin());
        for (int v: g[u]) {
            rm.emplace(s[v], v);
        }

        int v = parent[u];
        while (v > 1) {
            vals.erase(vals.find(val[v]));
            v = parent[v];
        }
        ans[u] = timer;
        if (!vals.empty())  {
            ans[u] -= *vals.rbegin();
        }
        v = u;
        while (v > 1) {
            val[v]++;
            vals.insert(val[v]);
            v = parent[v];
        }
        timer++;
    }


    while (q--) {
        int v;
        cin >> v;
        cout << ans[v] << " ";
    }
    return 0;
}
