
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int N = 3e5 + 3;
unordered_set<int> g[N];
int s[N], p[N];
int n;
vector<int> ob;
void calc(){
    vector<bool> was(n, false);

    int root = 0;
    while (true){
        was[root] = true;
        ob.push_back(root);
        int bst = -1;
        for (auto el : g[root]){
            if (was[el] ){
                continue;
            }
            if (bst == -1 ){
                bst = el;
            } else if (s[el] > s[bst]){
                bst = el;
            }
        }
        if (bst == -1) {
            break;
        }
        g[root].erase(bst);
        g[bst].erase(root);
        if (g[root].size() > g[bst].size()){
            swap(g[bst], g[root]);
        }
        for (auto el : g[root]){
            g[bst].insert(el);
        }
        root = bst;
    }
}
void dfs(int v, int pr){
    if (p[v] != 0 && p[v] != -1){
        if (p[p[v]] == 0){
            p[v] = p[v];
        } else {
            p[v] = p[p[v]];
        }
    }
    for (auto to : g[v]){
        if (pr != to){
            dfs(to, v);
        }
    }
}
signed main(){
    //ios::sync_with_stdio(0);
    //cin.tie(0);
    int q;
    cin >> n >>  q;
    p[0] = -1;
    for (int i = 1; i < n; i++){
        int x;
        cin >> x;
        x--;
        p[i] = x;
        g[i].insert(x);
        g[x].insert(i);
    }
    dfs(0, -1);
    for (int i = 0 ;i < n; i++){
        cin >> s[i];
    }
    calc();
    vector<int> cnt(n);
    set<pair<int, int>> st;
    vector<int> res(n);

    for (int  i= 0 ;i < n; i++){
        auto el = ob[i];
        if (p[el] == -1){
            cnt[el] = i;
            continue;
        }
        int up;
        if (p[el] == 0){
            up = el;
        } else {
            up = p[el];
        }
        //cout << el << " " << up << "\n";
        if (st.empty()){
            cnt[el] = i;
        } else {
            if ((*st.begin()).second == up){
                if (st.size() >= 2){
                    cnt[el] = i+(*(++st.begin())).first;
                } else{
                    cnt[el] = i;
                }
            } else {
                cnt[el] = i+(*st.begin()).first;
            }
        }
        st.erase({-res[up], up});
        res[up]++;
        st.insert({-res[up], up});
    }
    while (q--){
        int v;
        cin >> v;
        v--;
        cout << cnt[v] << " ";
    }
}
/*
6 6
1 1 1 4 5
2 3 4 5 6 1
1 2 3 4 5 6
 */