#include <bits/stdc++.h>

using namespace std;

vector<vector<pair<int, int>>> g;
vector<int> par;
vector<int> s;
vector<int> ans;

signed main() {
    int n, q;
    cin >> n >> q;
    g.resize(n);
    par.resize(n);
    for (int i = 1; i < n; i++) {
        cin >> par[i];
        par[i]--;
    }
    par[0] = -1;
    s.resize(n);
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 1; i < n; i++) {
        g[par[i]].push_back({s[i], i});
    }
    for (int i = 0; i < n; i++) {
        sort(g[i].rbegin(), g[i].rend());
    }
    ans.resize(n);
    set<pair<int, int>> cu;
    cu.insert({s[0], 0});
    int pos = 0;
    vector<int> h(n);
    multiset<int> res;
    for (int i = 0; i < n; i++) res.insert(0);
    while (!cu.empty()) {
        auto [w, v] = *(--cu.end());
        cu.erase(--cu.end());
        if (par[v] != -1) {
            res.erase(res.find(h[par[v]]));
            h[v] = h[par[v]]++;
            ans[v] = pos - *(--res.end());
            res.insert(h[v]);
        }
        pos++;
        for (auto [ww, uu] : g[v]) {
            cu.insert({ww, uu});
        }
    }
    for (int i = 0; i < q; i++) {
        int x;
        cin >> x;
        x--;
        cout << ans[x] << " ";
    }
}
