#include <bits/stdc++.h>

using namespace std;

void solve();

//#pragma GCC optimize("O3","Ofast","fastmath","unroll-loops")
//#pragma GCC target("avx2","sse4.2","bmi","lzcnt","popcnt")
int main() {
#ifdef LOCAL
    freopen("input.txt","r",stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

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

#define int long long
#define endl '\n'
const int N=3e5+10,INF=2e18,MOD=1e9+7;
vector<int> gr[N];

int tin[N],tout[N],timer=0;
bool used[N];
int par[N];
void dfs(int v){
    tin[v]=timer++;
    for(auto to:gr[v]){
        par[to]=v;
        dfs(to);
    }
    tout[v]=timer++;
}
bool upper(int f,int s){
    return tin[f]<=tin[s] && tout[f]>=tout[s];
}
void solve(){
    int n,q;
    cin>>n>>q;
    for(int i=1;i<n;i++){
        int p;
        cin>>p;
        p--;
        gr[p].push_back(i);
    }
    vector<int> ans(n,0),val(n,0);
    dfs(0);
    par[0]=-1;
    vector<int> s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    set<pair<int,int>> st;
    st.insert({-s[0],0});
    int cur=0;
    int mxa=0;
    while(!st.empty()){
        int v=st.begin()->second;
        used[v]=true;
        st.erase(st.begin());
        int mx=mxa;
        int curv=v;
        while(curv!=-1){
            val[curv]++;
            mxa=max(mxa,val[curv]);
            curv=par[curv];
        }
        ans[v]=cur-mx;
        for(auto to:gr[v]){
            st.insert({-s[to],to});
        }
        cur++;
    }
    for(int i=0;i<q;i++){
        int v;
        cin>>v;
        v--;
        cout<<ans[v]<<" ";
    }cout<<endl;
}