#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 tim = 0;
int n;

vector <int> g[300030];

void dfs(int v) {
    tin[v] = tim++;
    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];

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;
//        for(int i = 1; i <= n; i++) {
//            if(tin[i] <= tin[v] && tout[i] >= tout[v]) {
//                res[i]++;
//                continue;
//            }
//            del = max(del, res[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] << " ";
    }
}
