//#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;
vector<set<int>> pars;

void dfs(int u, vector<int>&used, set<int> &cp){
    used[u] = 1;
    pars[u] = cp;
    cp.insert(u);
    for(auto &v : g[u]){
        if(!used[v]) dfs(v, used, cp);
    }
    cp.erase(u);
}
void solve() {
    int n, q;
    cin >> n >> q;
    s.resize(n);
    g.resize(n);
    pars.resize(n);
    for(int i=1; i<n; ++i){
        int u; cin >> u; --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); set<int> cp;
    dfs(0, used, cp);
    for(auto &el : pars) assert(el.size() <= 100);
    vector<int> ans(q);
    set<pair<int, int>> vs;
    vector<int> sizes(n);
    int b = 0;
    for(auto &v : p){
        auto it = vs.end();
        if(v != 0 && pv[v] != -1){
            auto it = vs.rbegin();
            while(1){
                if(pars[v].find(it->second) == pars[v].end()){
                    ans[pv[v]] = b-it->first;
                    break;
                }
                ++it;
                if(it == vs.rend()){
                    ans[pv[v]] = b;
                    break;
                }
            }
        }
        for(auto &u : pars[v]){
            vs.erase(make_pair(sizes[u], u));
            ++sizes[u];
            vs.insert(make_pair(sizes[u], u));
        }
        sizes[v] = 1;
        vs.emplace(sizes[v], 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();
}