#include <bits/stdc++.h>

using namespace std;
#define int int64_t
vector<int> dist;
vector<vector<int> > a;
pair<bool, int> dfs(int v, int w) {
    if (v == w) {
        return {1, 0};
    }
    bool t = false;
    vector<pair<bool, int> > g(a[v].size());
    for (int i = 0; i < a[v].size(); i++) {
        int y = a[v][i];
        g[i] = dfs(a[v][i], w);
        if (g[i].first == true) {
            t = true;
        }
    }
    if (t == false) {
        int y = 0;
        if (dist[v] < dist[w]) {
            y++;
        }
        for (int i = 0; i < g.size(); i++) {
            y += g[i].second;
        }
    //cout << v << " " << w << " " << y << endl;
        return {0, y};
    }
    int ans = 0;
    for (int i = 0; i < g.size(); i++) {
        ans = max(ans, g[i].second);
    }
    return {1, ans};
}

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> p(n + 1, 0);
    a = vector<vector<int> >(n + 1);
    for (int i = 2; i <= n; i++) {
            cin >> p[i];
            a[p[i]].push_back(i);
    }
    vector<int> s(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
    }

    dist = vector<int>(n + 1, -1);
    int y = -1;
    set<pair<int,int>, greater<pair<int,int> > > st;
    st.insert({s[1], 1});
    while (st.size() > 0) {
        y++;
        auto it = st.begin();
        int v = (*st.begin()).second;
        st.erase(it);
        dist[v] = y;
        for (int i = 0; i < a[v].size(); i++) {
                int u = a[v][i];
            st.insert({s[u], u});
        }
    }
    for (int j = 0; j < q; j++) {
        int v;
        cin >> v;
        if (a[1].size() == 1) {
            cout << dist[v] << " ";
            continue;
        }
        pair<bool, int> f = dfs(1, v);
        cout << dist[v] - f.second << " ";
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}
