#include<bits/stdc++.h>
//#pragma GCCoptimize("Ofast,unroll-loops")
using namespace std;
#define int long long
#define ns cout << "\n";
#define ld long double
const int INF=1e9+7,N=1e6;
int n,q,timer=0;
vector<int>m,s,sz(N),p(N,-1),pr(N,-1),tin(N);
vector<vector<int>>a;
set<pair<int,int>>g;
void dfs(int i){
    m[i]=timer;
    timer++;
    for (auto j:a[i]){
        g.insert({-s[j],j});
    }
    if (g.size()==0){
        return;
    }
    pair<int,int> el=(*g.begin());
    g.erase(el);
    dfs(el.second);
}
void salesz(int i){
    sz[i]=1;
    for (auto j:a[i]){
        salesz(j);
        sz[i]+=sz[j];
    }
}
void BUILD_HLD(int i){
    tin[i]=timer;
    timer++;
    if (a[i].size()==0){
        return;
    }
    for (int j=1;j<a[i].size();++j){
        if(sz[a[i][j]]>sz[a[i][0]]){
            swap(a[i][0],a[i][j]);
        }
    }
    pr[a[i][0]]=i;
    p[a[i][0]]=p[i];
    BUILD_HLD(a[i][0]);
    for (int j=1;j<a[i].size();++j){
        pr[a[i][j]]=i;
        BUILD_HLD(a[i][j]);
    }
}
vector<int>t(N*4),k(N*4);
void push(int i){
    t[i*2]+=k[i];
    t[i*2+1]+=k[i];
    k[i*2]+=k[i];
    k[i*2+1]+=k[i];
    k[i]=0;
}
void ut(int i,int l,int r,int li,int ri){
    if (r<li || ri<l){
        return;
    }
    if (li<=l && r<=ri){
        t[i]+=1;
        k[i]+=1;
        return;
    }
    push(i);
    int s=(l+r)/2;
    ut(i*2,l,s,li,ri);
    ut(i*2+1,s+1,r,li,ri);
    t[i]=max(t[i*2],t[i*2+1]);
}
int mx(int i,int l,int r,int li,int ri){
    if (r<li || ri<l){
        return 0;
    }
    if (li<=l && r<=ri){
        return t[i];
    }
    push(i);
    int s=(l+r)/2;
    return max(mx(i*2,l,s,li,ri),mx(i*2+1,s+1,r,li,ri));
}
void PL(int i){
    while (i!=-1){
      //  cout<<tin[p[i]]<<' '<<tin[i]<<" PLUS"<<endl;
        ut(1,0,n-1,tin[p[i]],tin[i]);
        i=pr[p[i]];
    }
}
int ans(int i){
    int j=i;
    vector<pair<int,int>>a;
     while (i!=-1){
        a.push_back({tin[p[i]],tin[i]});
        i=pr[p[i]];
    }
    reverse(a.begin(),a.end());
    a.push_back({n,1});
    int w=0;

    for (int j=1;j<a.size();++j){
        w=max(w,mx(1,0,n-1,a[j-1].second+1,a[j].first-1));
    }
    return w;
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin>>n>>q;
    s.resize(n);
    m.resize(n);
    a.resize(n);
    for (int ij=1;ij<n;++ij){
        int x;
        cin>>x;
        a[x-1].push_back(ij);
    }
    for (int i=0;i<n;++i){
        cin>>s[i];
    }
    dfs(0);
    timer=0;
    for (int i=0;i<p.size();++i){
        p[i]=i;
    }
    salesz(0);
    BUILD_HLD(0);
    vector<pair<int,int>>b;
    for (int i=0;i<n;++i){
        b.push_back({m[i],i});
    }
    vector<int>re(n);
    sort(b.begin(),b.end());
    for (auto i:b){
        //i.second

        PL(i.second);
        re[i.second]=m[i.second]-ans(i.second);
       // cout<<m[i.second]-ans(i.second)<<' '<<i.first<<' '<<i.second<<' '<<endl;
    }
    for (auto i:re){
     //   cout<<i<<' ';
    }
    while (q--){
        int x;
        cin>>x;
        cout<<re[x-1]<<' ';
    }
}