#include <bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define int long long
const int INF = 1e18;

void solve1();

// typedef tree<int,null_type,less<>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    int qwerty = 1;
    // cin >> qwerty;
    while(qwerty--){
        solve1();
    }
}

void dfs(int v, int p, vector<vector<int>>& gr, vector<int>& ot){
    if(p == 0){
        ot[v] = v;
    }
    for(int u : gr[v]){
        ot[u] = ot[v];
        dfs(u, v, gr, ot);
    }
}

void solve1(){
    int n, q;
    cin >> n >> q;
    vector<vector<int>> gr(n);
    for(int i = 1; i < n; i++){
        int p;
        cin >> p;
        p--;
        gr[p].push_back(i);
    }
    vector<int> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    vector<int> ot(n);
    dfs(0, -1, gr, ot);
    set<pair<int, int>> st;
    st.insert({s[0], 0});
    vector<int> ans(n);
    int cc = 0;
    set<pair<int, int>> stt;
    vector<int> now(n);
    while(!st.empty()){
        auto x = *(--st.end());
        ans[x.second] = cc++;
        if(x.second != 0){
            if(!stt.empty()){
                auto it = --stt.end();
                bool flag = false;
                while(it != stt.begin()){
                    if((*it).second != ot[x.second]){
                        ans[x.second] -= (*it).first;
                        flag = true;
                        break;
                    }
                    --it;
                }
                if(!flag){
                     if((*it).second != ot[x.second]){
                        ans[x.second] -= (*it).first;
                        flag = true;
                    }
                }
            }
            stt.erase({now[ot[x.second]], ot[x.second]});
            now[ot[x.second]]++;
            stt.insert({now[ot[x.second]], ot[x.second]});
        }
        for(int u : gr[x.second]){
            st.insert({s[u], u});
        }
        st.erase(x);
    }
    while(q--){
        int x;
        cin >> x;
        cout << ans[x - 1] << ' ';
    }
}
