#include <bits/extc++.h>

using namespace std;

vector<vector<int>> g;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    g.resize(n);
    vector<int> p(n), h(n);
    for (int i = 1; i < n; i++) {
        cin >> p[i], p[i]--;
    }
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 1; i < n; i++) {
        h[i] = h[p[i]] + 1;
        g[p[i]].push_back(i);
    }
    int Y = -1;
    for (int i = 1; i < n; i++) {
        if (g[i].empty()) {
            Y = i;
            break;
        }
    }
    {
        int z = 0;
        while (true) {
            if ((int) g[z].size() != 1) {
                Y = z;
                break;
            }
            z = g[z][0];
        }
    }
    vector<int> ans(n, -1);
    {
        int z = Y;
        while (true) {
            ans[z] = h[z];
            if (z == 0) {
                break;
            }
            z = p[z];
        }
    }
    set<pair<int, int>> lol;
    vector<int> kek(n);
    int z = 0;
    for (int i = 1; i < n; i++) {
        h[i] = h[p[i]] + 1;
        if (p[i] == Y) {
            kek[i] = z++;
            lol.emplace(s[i], i);
        } else {
            kek[i] = kek[p[i]];
        }
    }
    vector<int> sz(z);
    multiset<int> suka;
    for (int i = 0; i < (int) g[Y].size(); i++) {
        suka.insert(0);
    }
    int timer = h[Y];
    while (!lol.empty()) {
        timer++;
        auto [_, v] = *lol.rbegin();
        lol.erase(--lol.end());
        suka.extract(sz[kek[v]]);
        ans[v] = timer;
        if (!suka.empty()) {
            ans[v] -= *suka.rbegin();
        }
        for (int to: g[v]) {
            lol.emplace(s[to], to);
        }
        sz[kek[v]]++;
        suka.insert(sz[kek[v]]);
    }
    while (q--) {
        int v;
        cin >> v, v--;
        cout << ans[v] << ' ';
    }
    return 0;
}
/*

5 4
1 2 2 1
3 5 1 2 4
5 3 1 4

 */