#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

#define int long long

const int maxn = 3e5 + 10;
const int inf = 1e9 + 7;
vector<int> parent(maxn, -1);
vector<vector<int>> edges(maxn, vector<int>());
vector<int> cost(maxn, 0);
vector<int> when_get_usual(maxn, 0);
vector<int> ans(maxn, inf);
vector<int> cou(maxn, 0);
vector<int> order_usual;
int n, q;
vector<int> tin(maxn, 0);
vector<int> tout(maxn, 0);
vector<int> global_p(maxn, 0);

void make_tin(int v, int & num) {
    tin[v] = num;
    num++;
    for (auto u : edges[v]) {
        make_tin(u, num);
    }
    tout[v] = num;
    num++;
}



void make_usual() {
    int v = 1;
    set<pair<int, int>> all;
    int timee = 1;
    while (true) {
        when_get_usual[v] = timee;
        ans[v] = min(ans[v], when_get_usual[v]);
        timee++;
        order_usual.push_back(v);
        for (auto u : edges[v]) {
            all.insert({cost[u], u});
        }
        if (all.size() == 0) {
            break;
        }
        pair<int, int> some = *all.rbegin();
        v = some.second;
        all.erase({cost[v], v});
    }
}

void sol() {
    set<pair<int, int>> all;
    for (auto v : order_usual) {
        all.insert({cou[v], v});
        if (v != 1 && edges[parent[v]].size() == 1 && parent[v] != 1 && parent[parent[v]] != 1) {
            parent[v] = parent[parent[v]];
        }
        int p = v;
        while (p != -1) {
            all.erase({cou[p], p});
            p = parent[p];
        }
        int q = 0;
        if (all.size() > 0) {
            q = (*all.rbegin()).first;
        }
        ans[v] = when_get_usual[v] - q;
        p = v;
        while (p != -1) {
            cou[p]++;
            all.insert({cou[p], p});
            p = parent[p];
        }
    }
}






signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
    cin >> n >> q;
    for (int i = 2; i <= n; i++) {
        int p;
        cin >> p;
        parent[i] = p;
        edges[p].push_back(i);
    }
    for (int i = 1; i <= n; i++) {
        if (parent[i] <= 1) {
            global_p[i] = i;
        } else {
            global_p[i] = global_p[parent[i]];
        }
    }
    for (int i = 1; i <= n; i++) {
        cin >> cost[i];
    }
    make_usual();
    sol();
    for (int i = 0; i < q; i++) {
        int num;
        cin >> num;
        cout << ans[num] - 1 << " ";
    }
    cout << endl;
}
