#include <bits/stdc++.h>

using namespace std;

using ll = long long;

vector<vector<int>> g;
vector<int> p, s;

void solve() {
    int n, q;
    cin >> n >> q;
    p.resize(n);
    g.resize(n);
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        g[p[i]].push_back(i);
    }
    s.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    set<array<int, 2>> st;
    st.insert({s[0], 0});
    vector<int> ans(n), cdel(n);
    vector<array<int, 2>> mx1(n, {0, 0});
    vector<array<int, 2>> mx2(n, {0, 0});
    int ord = 0;
    while (!st.empty()) {
        int u = (*st.rbegin())[1];
        st.erase({s[u], u});
        for (auto v : g[u]) {
            st.insert({s[v], v});
        }
        ans[u] = ord;
        int ou = u;
        int was = u;
        while (true) {
            cdel[u]++;
            if (mx1[u][0] != 0) {
                if (mx1[u][1] != was) {
                    ans[ou] = min(ans[ou], ord - mx1[u][0]);
                } else {
                    ans[ou] = min(ans[ou], ord - mx2[u][0]);
                }
            }
            if (u == 0) break;
            array<int, 2> nmx = {cdel[u], u};
            if (mx1[p[u]][1] == u) {
                mx1[p[u]][0] = cdel[u];
            } else if (mx2[p[u]][1] == u) {
                mx2[p[u]][0] = cdel[u];
                if (mx2[p[u]] > mx1[p[u]]) {
                    swap(mx1[p[u]], mx2[p[u]]);
                }
            } else if (mx1[p[u]] < nmx) {
                mx2[p[u]] = mx1[p[u]];
                mx1[p[u]] = nmx;
            } else if (mx2[p[u]] < nmx) {
                mx2[p[u]] = nmx;
            }
            was = u;
            u = p[u];
        }
        ord++;
    }
    for (int i = 0; i < q; i++) {
        int v;
        cin >> v;
        v--;
        cout << ans[v] << ' ';
    }
    cout << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    for (int i = 0; i < t; i++) solve();
}
