#include<bits/stdc++.h>

using namespace std;

#define int long long

const int MAXN = 3e5 + 31;

int p[MAXN];

int best[MAXN];
int s[MAXN];
int h[MAXN];
int uns[MAXN];

vector<int> g[MAXN];
int banned[MAXN];

set<pair<int, int>> now;

int rt[MAXN];

signed main(){
    int n, q;
    cin >> n >> q;
    set<pair<int, int>> now;
    h[0] = -1;
    set<pair<int, int>> lines;
    for(int i = 1; i < n; i++){
        cin >> p[i];
        p[i]--;
        h[i] = h[p[i]] + 1;
        if(p[i] == 0){
            rt[i] = i;
            lines.insert({0, i});
        }
        else{
            rt[i] = rt[p[i]];
        }
        g[p[i]].push_back(i);
    }
    best[0] = 0;
    for(int i = 0; i < n; i++){
        cin >> s[i];
        uns[s[i]] = i;
    }
    int sm = 0;
    int vv = 0;
    set<pair<int, int>> go;
    for(auto to : g[0]){
        go.insert({-s[to], to});
    }
    vector<int> ssv(n);
    while(1){
        if(vv != 0){
            best[vv] = sm;
            int del = 0;
            if(lines.begin()->second == rt[vv]){
                if(lines.size() > 1){
                    del = next(lines.begin())->first;
                }
            }
            else{
                del = lines.begin()->first;
            }
            best[vv] += del;
            lines.erase({ssv[rt[vv]], rt[vv]});
            ssv[rt[vv]]--;
            lines.insert({ssv[rt[vv]], rt[vv]});
        }
        sm++;
        if(go.empty()) break;
        int ch = go.begin()->second;
        go.erase(go.begin());
        vv = ch;
        for(auto to : g[vv]){
            go.insert({-s[to], to});
        }
    }
    while(q--){
        int x;
        cin >> x;
        x--;
        cout << best[x] << " ";
    }
}

