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

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

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

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

        int p = v;
        while (p){
            cnt[p]++;
            lvl[h[p]][1] = max(lvl[h[p]][1], cnt[p]);
            if (lvl[h[p]][0] < lvl[h[p]][1]) swap(lvl[h[p]][0], lvl[h[p]][1]);
            p = par[p];
        }

        visited++;
        if (!asked[v])
            continue;

        ans[asked[v]] = visited;
        p = v;
        while (p){
            if (lvl[h[p]][0] == cnt[p])
                ans[asked[v]] = min(ans[asked[v]], visited - lvl[h[p]][1]);
            else ans[asked[v]] = min(ans[asked[v]], visited - lvl[h[p]][0]);
            p = par[p];
        }
    }
}

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);
    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;
}