#include <bits/stdc++.h>

#pragma GCC optimize("O3")

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

int cnt[MAXN], total_cnt = 0;
bitset<MAXN> bs;

void del(int v) {
    cnt[val[v]]--;
    total_cnt--;
    if (cnt[val[v]] == 0) bs[MAXN - val[v] - 1] = false;
}

void add(int v) {
    val[v]++;
    if (cnt[val[v]] == 0) bs[MAXN - val[v] - 1] = true;
    cnt[val[v]]++;
    total_cnt++;
}

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];
    }

    int timer = 0;
    set<pair<int, int>, greater<>> rm = {{0, 1}};
    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) {
            del(v);
            v = parent[v];
        }
        ans[u] = timer;
        if (total_cnt) {
            ans[u] -= MAXN - bs._Find_first() - 1;
        }
        v = u;
        while (v > 1) {
            add(v);
            v = parent[v];
        }
        timer++;
    }


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