#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);
    vector<int> pr(n, -1);
    for(int i = 1; i < n; ++i){
        int p; cin>>p;
        --p;
        g[p].push_back(i);
        g[i].push_back(p);
        pr[i] = p;
    }
    vector<int> s(n);
    for(auto &x:s) cin>>x;
    vector<int> ord = {0};
    bool f = true;
    auto calc = [&](int ban, int vq) -> int{
        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);
            }
        };
        int res = n;
        for(int j = 1; j < n; ++j){
            nxt= -1;
            get(get, root);
            if (nxt == -1) {
                exit(1);
            }
            if (f) ord.push_back(nxt);
            if (nxt == vq){
                res = j;
            }
            used[nxt] = 1;
            root = nxt;
        }
        s[ban] = old;
        return res;
    };
    calc(0,0);
    f = false;
    vector<int> pos(n);
    for(int i = 0; i < n; ++i) pos[ord[i]] = i;
    while(q--){
        int v;
        cin>>v; --v;
        if (v == 0){
            cout<<0<<' ';
            continue;
        }
        int cur = calc(0,v);
        for(int j = pos[v]-1; j < pos[v]; ++j){
            cur=min(cur, calc(ord[j], v));
        }
        cout<<cur<<' ';
    }
    return 0;
}
