//#define _GLIBCXX_DEBUG
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")

#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
using ll = long long;
//#define int ll
using namespace std;
//using namespace __gnu_pbds;
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
//mt19937 mt(52);
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

vector<vector<int>> g;
vector<int> s;

int ct=0;
vector<int> tin, tout;
void dfs(int u, vector<int>&used){
    ++ct;
    used[u] = 1;
    tin[u] = ct;
    for(auto &v : g[u]){
        if(!used[v]) dfs(v, used);
    }
    ++ct;
    tout[u] = ct;
}
void ndfs(int pr, int u, vector<vector<int>> &ng, vector<int> &used, vector<int> &sz){
    used[u] = 1;
    for(auto &v: ng[u]) if(!used[v]) ndfs(u, v, ng, used, sz);
    if(ng[u].size() == 1 && ng[u][0] == pr) sz[u] = 1;
    else for(auto &v : ng[u]) if(v != pr) sz[u] += sz[v];
    sz[u]++;
} 
void dfs3(int pr, int u, vector<int> &used, vector<int> &pars){
    used[u] = 1;
    pars[u] = pr;
    for(auto &v : g[u]) if(!used[v]) dfs3((u == 0 ? v : pr), v, used, pars);
}
void solve() {
    int n, q;
    cin >> n >> q;
    s.resize(n);
    g.resize(n);
    tin.resize(n);
    tout.resize(n);
    vector<int> pars(n, -1);
    for(int i=1; i<n; ++i){
        int u; cin >> u; --u;
        pars[i] = u;
        g[u].push_back(i);
    }
    for(auto &el : s) cin >> el;
    vector<int> v(q), pv(n, -1);
    for(auto &el : v) {
        cin >> el; --el;
    }
    for(int i=0; i<q; ++i) pv[v[i]] = i;
    set<pair<int, int>> cur;
    vector<int> p;
    int root = 0;
    while(p.size() < n-1){
        p.push_back(root);
        for(auto &el : g[root]) cur.emplace(s[el], el);
        root = cur.rbegin()->second;
        cur.erase(*cur.rbegin());
    }
    p.push_back(root);
    //for(auto &el : p) cout << el+1 << ' ';
    vector<int> used(n);
    dfs(0, used);
    //for(auto &el : pars) assert(el.size() <= 100);
    vector<int> ans(q);
    set<pair<int, int>> vs;
    vector<int> sizes(n);
    int b = 0;
    vector<vector<int>> ng(n);
    used.assign(n, 0);
    dfs3(-1, 0, used, pars);
    
    for(auto &v : p){
        if(v != 0 && pv[v] != -1){
            auto it = vs.rbegin();
            ans[pv[v]] = b;
            if(it != vs.rend()) if(it->second == pars[v]) ++it;
            if(it != vs.rend()) ans[pv[v]] -= it->first;
        }
        if(pars[v] != -1) if(vs.find(make_pair(sizes[pars[v]], pars[v])) != vs.end()) vs.erase(make_pair(sizes[pars[v]], pars[v]));
        if(pars[v] != -1) ++sizes[pars[v]];
        if(pars[v] != -1) vs.insert(make_pair(sizes[pars[v]], pars[v]));
        ++b;
    }
    for(auto &el : ans) cout << el << ' ';
}


signed main(){
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    bool cfmode = !(42);
    if(cfmode){
        int t;
        cin >> t;
        while(t--){
            solve();
            cout << '\n';
        }
    } else solve();
}