#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), a.end()
void fst(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

const int maxn = 2e5;
set<pair<int, int>> g[maxn];
vector<int> ans;

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    fst();


    int n;cin >> n;

    int q;cin >> q;
    vector<int> p(n+1);
    vector<int> lvl(n+1);
    ans.resize(n+1);
    vector<int> nxt(n+1, -1);
    ans[1] = 1;
    p[1] = 1;
    for(int i = 2; i <= n; ++i){
        int x;cin >> x;
        p[i] = x;
        nxt[x] = i;
    }
    for(int i = 1; i <= n; ++i){
        cin >> lvl[i];
    }

    for(int i = 2; i <= n; ++i){
        int cur = p[i];
        int curlvl = lvl[i];
        g[cur].insert({curlvl, i});
    }
    if(g[1].size() == 1){
        while(q--){
            int v;cin >> v;
            cout << max(0LL, v-2) << " ";
        }
        return 0;
    } else {


        vector<int> path1, path2;
        ans[1] = 0;
        vector<int> sub;
        for(int i = 2; i <= n; ++i){
            if(p[i] == 1){
                sub.pb(i);
            }
        }

        int v1 = sub[0];
        int v2 = sub[1];
        if(lvl[v2] > lvl[v1]){
            swap(v2, v1);
        }

        ans[v1] = 0;
        int cur = nxt[v1];

        while(cur != -1){
            ans[cur] = ans[p[cur]]+1;
            cur = nxt[cur];
        }

        cur = nxt[v2];

        ans[v2] = 1;

        while(cur != -1){
            ans[cur] = ans[p[cur]]+1;
            cur = nxt[cur];
        }

        while(q--){
            int v;cin >> v;
            cout << ans[v] << " ";
        }
    }

}
