#include <bits/stdc++.h>

using namespace std;
#define int long long

const int N = (int) 1e5 * 3 + 10;

vector<int> g[N];

int p[N], s[N], ans[N], cur = 0, val[N], tin[N], tout[N], timer = 0;

void dfs(int v) {
    tin[v] = timer++;
    for (auto u: g[v])
        dfs(u);
    tout[v] = timer++;
}

bool anc(int u, int v) {
    return tin[u] <= tin[v] && tout[v] <= tout[u];
}

vector<int> tour;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    p[0] = -1;
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        --p[i], g[p[i]].emplace_back(i);
    }
    for (int i = 0; i < n; i++) cin >> s[i];
    dfs(0);
    set<pair<int, int>> neigh;
    for (auto u: g[0])
        neigh.insert({s[u], u});
    int ver = 0;
    while ((int) tour.size() < n) {
        tour.emplace_back(ver);
        if (!neigh.empty()) {
            ver = neigh.rbegin()->second;
            neigh.erase({s[ver], ver});
            for (auto u: g[ver])
                neigh.insert({s[u], u});
        }
    }
    multiset<int> pos;
    for (int i = 0; i < n; i++) pos.insert(0);
    for (int i: tour) {
        int v = i;
        while (v != -1) {
            pos.erase(pos.find(val[v]));
            v = p[v];
        }
        ans[i] = cur - *pos.rbegin();
        cur++;
        v = i;
        while (v != -1) {
            val[v]++;
            pos.insert(val[v]);
            v = p[v];
        }
    }
    for (int i = 0; i < q; i++) {
        int v;
        cin >> v;
        cout << ans[v - 1] << " ";
    }
    return 0;
}