#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("O3")

using namespace std;
//using namespace __gnu_pbds;

mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());

//#define int long long

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


signed main(){
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
    int n, q;
    cin>>n>>q;
    vector<vector<int> > g(n);
    for(int i = 1; i < n; ++i){
        int p; cin>>p;
        --p;
        g[p].push_back(i);
        g[i].push_back(p);
    }
    vector<int> s(n);
    for(auto &x:s) cin>>x;
    auto calc = [&](int ban) -> vector<int>{
        vector<int> ord = {0};
        int root = 0;
        vector<int> used(n);
        used[root] = 1;
        int old = s[ban];
        s[ban] = 0;

        int nxt = -1;

        auto get = [&](auto self, int v, int p = -1) -> void{
            if (!used[v]){
                if (nxt == -1 || s[nxt] < s[v]){
                    nxt = v;
                }
                return;
            }
            for(int u:g[v]){
                if (u == p) continue;
                self(self, u, v);
            }
        };
        for(int j = 1; j < n; ++j){
            nxt= -1;
            get(get, root);
            if (nxt == -1) {
                exit(1);
            }
            ord.push_back(nxt);
            used[nxt] = 1;
            root = nxt;
        }
        s[ban] = old;
        return ord;
    };
    vector<int> ans(n, n);
    ans[0] = 0;
    for(int ban = 0; ban < 1; ++ban){
        auto t = calc(ban);
        for(int i = 1; i < n; ++i){
            ans[t[i]] = min(ans[t[i]], i);
        }
    }
    while(q--){
        int v;
        cin>>v; --v;
        cout<<max(0, ans[v] - 1)<<' ';
    }
    return 0;
}
