#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;
    {
        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];
        }
    }
//    cerr << "???????\n";
    set<pair<int, int>> lol;
    vector<int> kek(n);
    int z = 0;
    for (int i = 1; i < n; i++) {
        if (p[i] == Y) {
            kek[i] = z++;
            lol.emplace(s[i], i);
        } else {
            if (ans[i] == -1) {
                kek[i] = kek[p[i]];
            }
        }
    }
    vector<int> sz(n);
    vector<multiset<int>> suka(n);
    for (int i = 0; i < n; i++) {
        for (int t = 0; t < (int)g[i].size(); t++) {
            suka[i].insert(0);
        }
    }
    int timer = h[Y];
//    cerr << "!!!!!!!!\n";
    while (!lol.empty()) {
//        cerr << "!!!!\n";
        timer++;
        auto [_, v] = *lol.rbegin();
        lol.erase(--lol.end());
        ans[v] = timer;
        for (int R = v; R != Y; R = p[R]) {
//            cerr << "!! " << R + 1 << '\n';
            suka[p[R]].extract(sz[R]);
            if (!suka[p[R]].empty()) {
                ans[v] = min(ans[v], timer - *suka[p[R]].rbegin());
            }
        }
        for (int to: g[v]) {
            lol.emplace(s[to], to);
        }
        for (int R = v; R != Y; R = p[R]) {
//            cerr << "!! " << R + 1 << '\n';
            sz[R]++;
            suka[p[R]].insert(sz[R]);
        }
    }
    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

 */