#include <bits/extc++.h>
using namespace std;
#define int long long
mt19937 rnd(time(0));
const int MAX_N = 3e5 + 23;
int p[MAX_N], s[MAX_N];
int pos[MAX_N], sz[MAX_N];
vector<int> pp[MAX_N];
vector<pair<int, int>> g[MAX_N];
set<pair<int, int>> st;
int cnt = 0;
vector<int> g1[MAX_N];
int tim = 0;
int tin[MAX_N], tout[MAX_N];
void dfs1(int v){
    tin[v] = tim;
    tim++;
    for(auto u:g1[v]){
        dfs1(u);
    }
    tout[v] = tim;
}
bool check(int u, int v){
    return (tin[u] <= tin[v] && tout[v] <= tout[u]);
}
void dfs(int v){
    sz[v]++;
    for(auto [k, u]:g[v]){
        dfs(u);
        sz[v] += sz[u];
    }
}
void pos_get(int v){
    int op;
    for(auto [val, key]:st){
        if(!check(key, v)){
            op = val;
            break;
        }
    }
    pos[v] = cnt + op;
    cnt++;
    for(auto [k, u]:g[v]){
        //cout << u << " " << m[v] << " " << sz[u] << "\n";
        pos_get(u);
        for(auto f:pp[u]){
            sz[f] += sz[u];
            st.insert({-sz[f], f});
        }
        st.insert({-sz[u], u});
    }
}
void solve(){
    int n, q;
    cin >> n >> q;
    st.insert({0, -1});
    for(int i = 1; i < n; i++){
        cin >> p[i];
        p[i]--;
        g1[p[i]].push_back(i);
    }
    dfs1(0);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    for(int i = 1; i < n; i++){
        while(p[i] != 0 && s[i] < s[p[i]]){
            pp[i].push_back(p[i]);
            p[i] = p[p[i]];
        }
    }
    for(int i = 1; i < n; i++){
        g[p[i]].emplace_back(s[i], i);
    }
    for(int i = 0; i < n; i++){
        sort(g[i].begin(), g[i].end());
        reverse(g[i].begin(), g[i].end());
    }
    dfs(0);
    pos_get(0);
    for(int i = 0; i < q; i++){
        int k;
        cin >> k;
        k--;
        cout << pos[k] << " ";
    }
    cout << "\n";
}
signed main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int tim = clock();
    int tt =  1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    //cout << (long double)(clock() - tim) / CLOCKS_PER_SEC << "\n";
}
