// #include <string>
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

using ld = long double;
using ll = long long;

//#define int long long

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

void dfs(int u, int pre, int &c, vector<int> &clr) {
    if (p[u] == 0) {
        clr[u] = c;
        c++;
    } else if (u != 0) {
        clr[u] = clr[p[u]];
    }
    for (auto v : g[u]) {
        if (v != pre) {
            dfs(v, u, c, clr);
        }
    }
}

void solve() {
    int q, x;
    cin >> n >> q;
    g.resize(n);
    p.resize(n);
    s.resize(n);
    p[0] = -1;
    for (int i = 1; i < n; ++i) {
        cin >> p[i];
        p[i]--;
        g[i].push_back(p[i]);
        g[p[i]].push_back(i);
    }
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    int c = 1;
    vector<int> clr(n), cnt(n);
    dfs(0, -1, c, clr);
    vector<int> ord;
    set<pair<int, int>> st;
    st.insert({s[0], 0});
    while (!st.empty()) {
        int u = (--st.end())->second;
        st.erase(--st.end());
        ord.push_back(u);
        for (auto v : g[u]) {
            if (v != p[u]) {
                st.insert({s[v], v});
            }
        }
    }
    vector<int> nord(n);
    for (int i = 0; i < n; ++i) {
        nord[i] = clr[ord[i]];
    }
    vector<int> is(n, -1);
    for (int i = 0; i < q; ++i) {
        cin >> x;
        x--;
        is[x] = i;
    }
    pair<int, int> mx1 = {0, -1}, mx2 = {0, -1};
    vector<int> ans(q);
    for (int i = 0; i < n; ++i) {
        if (ord[i] == 1) {
            int af = 1;
        }
        if (is[ord[i]] != -1) {
            if (nord[i] == mx1.second)
                ans[is[ord[i]]] = i - mx2.first;
            else
                ans[is[ord[i]]] = i - mx1.first;
        }
        cnt[nord[i]]++;
        if (nord[i] == 0)
            continue;
        if (mx1.first >= cnt[nord[i]])
            mx2 = max(mx2, {cnt[nord[i]], nord[i]});
        else {
            mx1 = {cnt[nord[i]], nord[i]};
        }
    }
    //cout << q << '\n';
    for (auto i : ans) {
        cout << i << ' ';
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int tt = 1;
    //cin >> tt;
    for (int i = 0; i < tt; ++i) {
        solve();
        //cout << '\n';
    }
}