#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define pb push_back

using namespace std;

int p[300030];
int s[300030];
int ans[300030];
int tin[300030], tout[300030];
int p2[300030];
int tim = 0;
int n;

vector <int> g[300030];

void dfs(int v) {
    tin[v] = tim++;
    if(v != 1) {
        if(p[v] == 1)
            p2[v] = v;
        else p2[v] = p2[p[v]];
    }
    for(auto to : g[v]) {
        dfs(to);
    }
    tout[v] = tim++;
}

void add(int v, set <pair<int, int>> &st) {
    for(auto to : g[v]) {
        st.insert({s[to], to});
    }
}

int res[300030];
pair <int, int> res2[300030];

void f() {
    set <pair<int, int>> st;
    add(1, st);
    int day = 0;
    while(!st.empty()) {
        day++;
        auto [mx, v] = *(--st.end());
        st.erase(--st.end());
        int del = 0;
        int i = p2[v];
        int lst = 0;
        while(i >= 1) {
            res[i]++;
            if(i != 1) {
                int pr = p[i];
                if(res2[pr].S == i) {
                    int x = res[res2[pr].F];
                    if(res[i] > x)
                        swap(res2[pr].F, res2[pr].S);
                }
                else if(res2[pr].F != i) {
                    int x = res[res2[pr].F];
                    int y = res[res2[pr].S];
                    if(res[i] > x) {
                        swap(res2[pr].F, res2[pr].S);
                        res2[pr].F = i;
                    }
                    else if(res[i] > y) {
                        res2[pr].S = i;
                    }
                }
            }
            if(i != v) {
                if(res2[i].F != lst)
                    del = max(del, res[res2[i].F]);
                else del = max(del, res[res2[i].S]);
            }
            //del = max(del, res2[i]);
            lst = i;
            i = p[i];
        }
        ans[v] = day - del;
        add(v, st);
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // LOCAL
    int q;
    cin >> n >> q;
    for(int i = 2; i <= n; i++) {
        cin >> p[i];
        g[p[i]].pb(i);
    }
    for(int i = 1; i <= n; i++) {
        cin >> s[i];
    }
    dfs(1);
    f();
    while(q--) {
        int v;
        cin >> v;
        cout << ans[v] << " ";
    }
}
