#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);
    }
    vector<int> tin(n), tout(n);
    int _t = 0;
    auto dfs = [&](auto self, int v) -> void{
        tin[v] = _t++;
        for(int u:g[v]){
            self(self, u);
        }
        tout[v] = _t;
    };
    dfs(dfs, 0);
    auto ok = [&](int u, int v) -> bool{
        return tin[u] <= tin[v] && tin[v] < tout[u];
    };
    vector<int> s(n);
    for(auto &x:s) cin>>x;
    priority_queue<pair<int,int> > qq;
    qq.emplace(s[0], 0);
    vector<int> ord;
    while(!qq.empty()){
        auto [val, v ] = qq.top();
        qq.pop();
        ord.push_back(v);
        for(int u:g[v]){
            qq.emplace(s[u], u);
        }
    }
    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;
        }
        //cout<<pos[v]<<" : \n";
        int ans = pos[v];
        for(int ban = 1; ban < n; ++ban){
            if (ok(ban, v)) continue;
            int cnt = (pos[ban] < pos[v]);
            bool ok = true;
            for(int u:g[ban]){
                if (u == v) ok = false;
                cnt += (pos[u] < pos[v]);
            }
            //cout<<ban<<' '<<cnt<<endl;
            if (ok){
                ans = min(ans, pos[v] - cnt);
            }
        }
        cout<<ans<<' ';
    }
    return 0;
}
