#include <bits/stdc++.h>
using namespace std;

const int N = 3e5 + 100;
int n, q, par[N], anc[N], a[N], h[N], ans[N], asked[N], cnt[N], lvl[N][2];
vector<int> g[N];
priority_queue<pair<int, int>> order;
set<pair<int, int>> st;

void traverse(int v){
    int visited = 0;
    order.push({a[v], v});
    while (!order.empty()){
        int v = (order.top()).second;
        order.pop();
        visited++;

        h[v] = h[par[v]] + 1;
        for (int u : g[v])
            order.push({a[u], u});

        ans[asked[v]] = visited;
        if (v == 1) continue;

        st.erase({cnt[anc[v]], anc[v]});
        cnt[anc[v]]++;
        st.insert({cnt[anc[v]], anc[v]});

        int i = 0;
        auto it = st.end();
        while (it != st.begin() and i < 2){
            i++;
            it--;
            if ((*it).second == anc[v]) continue;
            ans[asked[v]] = min(ans[asked[v]], visited - (*it).first);
        }
    }
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);

    cin >> n >> q;
    for (int i = 2; i <= n; i ++){
        cin >> par[i], g[par[i]].push_back(i);
        if (par[i] == 1) anc[i] = i;
        else anc[i] = anc[par[i]];
    }
    for (int i = 1; i <= n; i ++)
        cin >> a[i];

    for (int i = 1; i <= q; i ++){
        int v;
        cin >> v;
        asked[v] = i;
    }

    traverse(1);

    for (int i = 1; i <= q; i ++)
        cout << ans[i] - 1 << ' ';
    cout << endl;
}