#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template<class T> using oset = tree<T, null_type, less_equal<>, rb_tree_tag, tree_order_statistics_node_update>;

//#define int long long
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
int inf = 1e9;
int n;
const int N = 3e5;
vector<int> kids[N];
int p[N], s[N];
int tin[N], tout[N];
int t = 0;
void dfs(int v){
    tin[v] = t++;
    for(auto u : kids[v]){
        dfs(u);
    }
    tout[v] = t++;
}

int ord[N];
int where[N];

void initord(){
    set<pair<int, int>> gg;
    gg.insert({s[0], 0});
    int time =0 ;
    while(!gg.empty()){
        int v = gg.rbegin()->second;
        ord[time] = v;
        where[v] = time;
        time++;
        for(auto x : kids[v]){
            gg.insert({s[x], x});
        }
        gg.erase({s[v], v});
    }
}
void solve() {
    int q ;
    cin >> n >> q;
    p[0] = -1;
    for(int i = 1; i < n; ++i){
        cin >> p[i];
        p[i]--;
        kids[p[i]].push_back(i);
    }
    for(int i = 0; i < n; ++i){
        cin >> s[i];
    }
    dfs(0);
    initord();
    vector<vector<int>> z;
    int op = 0;
    vector<pair<int, int>> ans;
    while(q--){
        int d;
        cin >>d;
        d--;
        z.push_back({where[d],d,op});
        op++;
    }
    sort(all(z));
    oset<int> s;
    int cur = 0;
    if(z[cur][1] == 0){
        ans.push_back({z[cur][2], 0});
        cur++;
    }
    if(cur <  z.size()){
        for(int i = 1; i < n; ++i){
            int an = inf;
            if(z[cur][0] == i){
                int d = z[cur][1];
                int cnt =0 ;
                for(int x = 1; x < where[d]; ++x){
                    if(tin[d] >= tin[x] && tin[d] <= tout[x]){
                        continue;
                    }
                    cnt += s.order_of_key(tout[x]) - s.order_of_key(tin[x]);
                    an = min(an, i - cnt);
                }
                ans.push_back({z[cur][2], an});
                cur++;
            }
            if(cur == z.size()){
                break;
            }
            s.insert(tin[i]);
        }
    }

    sort(all(ans));
    for(auto x : ans){
        cout << x.second << " ";
    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
        cout << '\n';
    }
    return 0;
}
