#include <bits/stdc++.h>

#define ll long long

using namespace std;

void fast_in_out() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
vector<ll> g[300010];
ll root=1;
vector<ll> vc;
vector<pair<pair<ll,ll>,ll>> zp;
ll w[300010],ans[300010],p[300010],tin[300010],tout[300010],t=0,to[300010],cnt[300010];
multiset<ll> s;
ll up[23][300010],c[23][300010];
void dfs(ll v){
    tin[v]=t++;
    if(to[v]==0 && v!=root)to[v]=v;
    for(auto u:g[v]){
        if(v!=root)to[u]=to[v];
        dfs(u);
    }
    tout[v]=t++;
}
bool ch(ll v,ll u){
    if(tin[v]<=tin[u] && tout[u]<=tout[v])return true;
    return false;
}
bool comp(ll v,ll u){
    if(ch(v,u))return true;
    if(ch(u,v))return false;
    ll i,mnv=1e9,mnu=1e9;
    for(i=20;i>=0;i--){
        if(!ch(up[i][v],u)){
            mnv=min(mnv,c[i][v]);
            v=up[i][v];
        }
    }
    mnv=min(mnv,c[0][v]);
    for(i=20;i>=0;i--){
        if(!ch(up[i][u],v)){
            mnu=min(mnu,c[i][u]);
            u=up[i][u];
        }
    }
    mnu=min(mnu,c[0][u]);
    if(mnv>mnu)return true;
    return false;
}

int main() {
    fast_in_out();
    ll n,i,q,x,v,j;
    cin >> n >> q;
    up[0][1]=1;
    for(i=2;i<=n;i++)ans[i]=-1;
    for(i=2;i<=n;i++){
        cin >> p[i];
        s.insert(0);
        up[0][i]=p[i];
        g[p[i]].push_back(i);
    }
    while(g[root].size()==1){
        tin[root]=t++;
        tout[root]=2*n+1-tin[root];
        root=g[root][0];
        ans[root]=0;
    }
    s.insert(0);
    for(i=1;i<=n;i++)cin >> w[i],vc.push_back(i),c[0][i]=w[i];
    dfs(root);
    for(j=1;j<=20;j++){
        for(i=1;i<=n;i++){
            up[j][i]=up[j-1][up[j-1][i]];
            c[j][i]=min(c[j-1][i],c[j-1][up[j-1][i]]);
        }
    }
    ll cnt1=0;
    sort(vc.begin(),vc.end(),comp);
    for(auto u:vc){
        if(ans[u]!=-1){
            ans[u]=cnt1;
            cnt1++;
        }else {
            ll mx = *s.rbegin();
            if (cnt[to[u]] == mx) {
                s.erase(s.find(cnt[to[u]]));
                ans[u] = cnt1 - (*s.rbegin());
                s.insert(cnt[to[u]]);
            } else {
                ans[u] = cnt1 - (*s.rbegin());
            }
            s.erase(s.find(cnt[to[u]]));
            cnt[to[u]]++;
            s.insert(cnt[to[u]]);
            cnt1++;
        }
    }
    while(q--){
        cin >> v;
        cout << ans[v] << " ";
    }
    return 0;
}
