#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
mt19937 rnd(time(NULL));
vector<vector<int>>graph;
vector<int>c; int cnt = 0;
set<pair<int, int>>del; vector<int>num; vector<pair<int, int>>best;
vector<int>change; vector<int>sum;
vector<int>p; vector<int>comp;
void ans(int start) {
    num[start] = cnt; cnt++;
    int last = comp[start];
    if(last != -1){
        if(sum[last] == best[0].first) {
            change[start] = max(change[start], best[0].second); best[0].first++;
        }
        else{
            change[start] = max(change[start], best[0].first);
            if(sum[last] == best[0].second){
                best[0].second++;
            }
        }
        sum[last]++;
    }
    pair<int, int>val = {-1, -1};
    for(auto v: graph[start]){
        if(val.first < c[v]){
            val.first = c[v]; val.second = v;
        }
    }
    if(!del.empty()) val = max(val, *(--del.end()));
    if(val.first == -1) return;
    for(auto v: graph[start]){
        del.insert({c[v], v});
    }
    del.erase(val); change[val.second] = best[p[val.second] - 1].first;
    if(p[val.second] == 0) ans(val.second);
    else ans(val.second);
}
void dfs(int start, int last){
    comp[start] = last;
    for(auto val: graph[start]){
        if(last == -1) dfs(val, val);
        else dfs(val, last);
    }
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, q; cin >> n >> q; num.resize(n); change.resize(n); comp.resize(n, -1);
    p.resize(n); graph.resize(n); c.resize(n); sum.resize(n);
    for(int i = 0; i < n - 1; i++){
        cin >> p[i + 1];
    }
    for(int i = 0; i < n; i++) cin >> c[i];
    for(int i = 0; i < n - 1; i++){
        graph[p[i + 1] - 1].push_back(i + 1);
    }
    best.resize(n, {0, 0}); dfs(0, -1); ans(0);
    while(q--){
        int v; cin >> v; v--; cout << num[v] - change[v] << " ";
    }
    return 0;
}