
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define int long long
const int N = 3e5 + 3;
vector<int> g[N];
int s[N], p[N];
int n;
set<int> nowg[N];
vector<int> ob;
void calc(){
    //vector<bool> was(n, false);
    for (int i = 0 ;i < n; i++){
        nowg[i].clear();
        for (auto el : g[i]){
            nowg[i].insert(el);
        }
    }
    int root = 0;
    int res = 0;
    while (!nowg[root].empty()){
        //cout << root << "\n";
        ob.push_back(root);
        res++;
        int bst = -1;
        for (auto el : nowg[root]){
            if (bst == -1 ){
                bst = el;
            } else if (s[el] > s[bst]){
                bst = el;
            }
        }
        for (auto el : nowg[root]){
            nowg[el].erase(root);
            if (el != bst){
                nowg[bst].insert(el);
            }
        }
        nowg[root].clear();
        root = bst;
    }
    ob.push_back(root);
}
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].push_back(x);
        g[x].push_back(i);
    }
    for (int i = 0 ;i < n; i++){
        cin >> s[i];
    }
    dfs(0, -1);
    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
 */