#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define all(a) a.begin(), a.end()
vector<vector<int>> g;
vector<int> p, s, p2;
set<pair<int, int>> cur;
vector<int> way;
vector<int> ind;
void dfs(int u) {
    way.push_back(p2[u]);
    ind[u] = (int) way.size() - 1;
    for (auto to: g[u]) {
        if (u != 0) {
            p2[to] = p2[u];
        } else {
            p2[to] = to;
        }
        cur.insert({s[to], to});
    }
    if (cur.empty()) {
        return;
    }
    int v = (*--cur.end()).second;
    cur.erase(--cur.end());
    dfs(v);
}
void solve() {
    int n, q;
    cin >> n >> q;
    p.resize(n), s.resize(n), g.resize(n), p2.resize(n, 0);
    ind.resize(n);
    for (int i = 1; i < n; ++ i) {
        cin >> p[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    for (int i = 1; i < n; ++i) {
        p[i]--;
        g[p[i]].push_back(i);
    }
    dfs(0);
    map<int, int> cnt;
    int mx1 = -1, mx2 = -1;
    int fx1 = 0;
    vector<int> ans(n, 1);
    ans[0] = 0;
    for (int i = 0; i < n; ++i) {
        ans[i] = ind[i];
    }
    for (int i = 1; i < n; ++i) {
        if (mx1 != -1 && fx1 == way[ind[i]]) {
            ans[i] = ind[i] - mx2;
        } else if (mx2 != -1) {
            ans[i] = ind[i] - mx1;
        }
        cnt[way[ind[i]]]++;
        if (mx1 < cnt[way[ind[i]]]) {
            mx2 = mx1;
            fx1 = way[ind[i]];
            mx1 = cnt[way[ind[i]]];
        } else if (mx2 < cnt[way[ind[i]]]) {
            mx2 = cnt[way[ind[i]]];
        }
    }
    for (int i : g[0]) {
        ans[i] = 1;
    }
    while (q--) {
        int v;
        cin >> v;
        cout << ans[v - 1] << ' ';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
