#include <bits/stdc++.h>
#define pb push_back
#define endl "\n"
// #define pb push_back
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int maxn = 3e5 + 10;
vector<int> g[maxn];
int p[maxn];
int s[maxn];
int ans[maxn];
int cnt[maxn];

struct cmp{
    bool operator()(const int &u, const int &v) const{
        return s[u] > s[v];
    }
};

struct cmp1{
    bool operator()(const int &u, const int &v) const{
        if (cnt[u] != cnt[v]) return cnt[u] > cnt[v];
        return u < v;
    }
};

set<int, cmp1> pos;
int timer = 0;
int tin[maxn], tout[maxn];

void dfs(int u){
    tin[u] = timer++;
    for (auto v : g[u]){
        dfs(v);
    }
    tout[u] = timer++;
}

bool is_pr(int u, int v){
    return tin[u] < tin[v] && tout[u] > tout[v];
}


int get_ans(int u){
    int op = 0;
    for (auto v : pos){
        ++op;
        if (op > 2) cnt[u] = 1 / 0;
        if (is_pr(v, u)) continue;
        return cnt[v];
        
    }
}

int boss[maxn];

void upd(int u){
    if (u == 0) return;
//    while (u != 0){
//        pos.erase(u);
//        cnt[u]++;
//        pos.insert(u);
//        u = p[u];
//    }
    pos.erase(boss[u]);
    cnt[boss[u]]++;
    pos.insert(boss[u]);
}



void dfs1(int u, int king){
    boss[u] = king;
    for (int v : g[u]){
        if (u == 0) dfs1(v, v);
        else dfs1(v, king);
    }
}


void solve(){
    int n, q;
    cin >> n >> q;
    for (int i = 1; i < n; ++i){
        int pr;
        cin >> pr;
        pr--;
        g[pr].pb(i);
        p[i] = pr;
    }
    dfs(0);
    dfs1(0, 0);
    for (int i = 0; i < n; ++i){
        cin >> s[i];
    }
    set<int, cmp> now;
    now.insert((ll)0);
    for (int u : g[0]){
        pos.insert(u);
    }
    int now_cnt = 0;
    while (!now.empty()){
        int u = *now.begin();
        now.erase(u);
        for (auto v : g[u]) now.insert(v);
        // get_ans
        ans[u] = now_cnt - get_ans(u);
        // upd
        upd(u);
        ++now_cnt;
    }
    while (q--){
        int v;
        cin >> v;
        v--;
        cout << ans[v] << " ";
    }
}



signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--){
        solve();
    }
}