#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using ll = long long;
using ld = long double;
#define all(array) array.begin(), array.end()
constexpr long long INF =  (long long)2e18 + 1;
constexpr ll inf = 1e9 + 1;
const ll mod = 1e9 + 7;


vector<int> p;
vector<vector<int>> g;
vector<pair<ll,ll>> dp;
vector<ll> ans;
vector<ll> vec;
/*
void dfs(int v){
    dp[v].first = dp[par].first;
    dp[v].second



    ans[v] = min();
    for(int u : g[v]){
       if(u  != par){
           dfs(u, v);
       }
   }

}
*/
void bfs(int s){
    set<pair<ll,ll>> q;
    q.insert({-vec[0], 0});
    ll cnt = 0;
    while(!q.empty()){
        auto v = *q.begin();
        ans[v.second] = min(cnt++,ans[v.second]);
        q.erase(v);
        for(ll u : g[v.second]){
            q.insert({-vec[u], u});
        }
    }
}
vector<ll> d;
void dfs2(int v){
    for(int u : g[v]){
        ans[u] = ans[v] + 1;
        dfs2(u);
    }
}

void solve(){
    ll n,q;
    cin >> n >> q;
    p.resize(n);
    g.resize(n);
    dp.resize(n);
    ans.assign(n, 0);
    vec.resize(n);
    for(int i = 0 ; i < n- 1; ++i){
        int x;
        cin >> x;
        x--;
        p[1 + i] = x;
        g[x].push_back(1 + i);
    }
    for(int i =0 ;i < n; ++i){
        cin >> vec[i];
    }

    dfs2(0);
    for(int i = 0;i < q; ++i){
        int qwe;
        cin >> qwe;
        cout << ans[qwe-1] << " ";
    }



}


signed main(){
    fast;;;
    long long tc = 1;
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    cin >> tc;
#endif
    //cin >> tc;
    while(tc--){
        solve()
        ;
        cout << "\n";
    }


}