#include <bits/extc++.h>

using namespace std;
using namespace __gnu_pbds;

#define itn int
//#define int long long
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
#define pii pair<int, int>
#define ff first
#define ss second
#define sz(a) (int)(a).size()
#define ll long long
#define ld long double

mt19937 rnd(time(0));

const int N = 3e5 + 10;

vector <int> g[N];
int s[N];
int al;

set <pii> our;

itn used[N];
int ans[N];
itn tin[N], tout[N];
int d = 0;

void dfs(int v, int p){
    al++;
    ans[v] = al - 1;
    used[v] = 1;
    for (auto x: g[v]){
        if (used[x]) continue;
        our.insert({-s[x], x});
    }
    set<pii> vsp = our;
    for (auto [w, x]: vsp){
        if (!used[x]){
            our.erase({w, x});
            dfs(x, v);
        }
    }
}
itn h[N];

void to_p(int v, int p){
    tin[v] = d++;
    for (auto x: g[v]){
        if (x == p) continue;
        h[x] = h[v] + 1;
        to_p(x, v);
    }
    tout[v] = d++;
}



void solve(){
    itn n, q;
    cin >> n >> q;
    vector <itn> pr(n);
    for (int i = 1; i < n; ++i){
        int p;
        cin >> p;
        p--;
        pr[i] = p;
        g[i].push_back(p);
        g[p].push_back(i);
    }

    for (int i = 0; i < n; ++i){
        cin >> s[i];
    }

    to_p(0, -1);

    unordered_set <int> uk;
    for (itn i = 1; i < n; ++i){
        if (pr[i] == 0){
            uk.insert(i);
        }
    }

    vector <int> posl;
    vector <int> ANS(n);
    int cur_sm = 0;
    set<pii> cur_mx;
    while (!uk.empty()){
        pii nxt = {-1, -1};
        for (auto x: uk){
            if (sz(g[x]) == 2) {
                if (nxt.ff == -1 || (s[nxt.ff] < s[x])) {
                    nxt.ff = x;
                    for (auto y: g[x]) {
                        if (y == pr[x]) continue;
                        nxt.ss = y;
                    }
                }
            }
            else if (sz(g[x]) == 1){
                if (nxt.ff == -1 || (s[nxt.ff] < s[x])) {
                    nxt.ff = x;
                    nxt.ss = -1;
                }
            }
        }
        posl.push_back(nxt.ff);

        cur_sm++;

        if (cur_mx.empty()){
            ANS[nxt.ff] = cur_sm;
        }
        else if ((*cur_mx.rbegin()).ss != nxt.ff){
            ANS[nxt.ff] = cur_sm - (*cur_mx.rbegin()).ff;
        }
        else if (sz(cur_mx) >= 2){
            ANS[nxt.ff] = cur_sm - (*--(prev(cur_mx.end()))).ff;
        }
        else{
            ANS[nxt.ff] = cur_sm;
        }


        uk.erase(nxt.ff);
        if (nxt.ss != -1) {
            uk.insert(nxt.ss);
        }
        cur_mx.erase({h[nxt.ff] - 1, nxt.ff});
        cur_mx.insert({h[nxt.ff], nxt.ss});
    }
    while (q--){
        itn v;
        cin >> v;
        v--;
        cout << ANS[v] << ' ';
    }
}

signed main(){
    cin.tie(nullptr) ->sync_with_stdio(false);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
//    cin >> t;
    while (t--){
        solve();
    }
}