#include <bits/stdc++.h>

using namespace std;

vector<vector<pair<int, int>>> g;
vector<int> par;
vector<int> s;
vector<int> ans;
int pos = 0, res = 0;

int dfs(int v) {
    int sz = 1;
    ans[v] = pos - res;
    pos++;
    sort(g[v].rbegin(), g[v].rend());
    for (auto [w, u] : g[v]) {
        sz += dfs(u);
    }
    res = max(res, sz);
    return sz;
}

signed main() {
    int n, q;
    cin >> n >> q;
    g.resize(n);
    par.resize(n);
    for (int i = 1; i < n; i++) {
        cin >> par[i];
        par[i]--;
    }
    s.resize(n);
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 1; i < n; i++) {
        g[par[i]].push_back({s[i], i});
    }
    ans.resize(n);
    dfs(0);
    for (int i = 0; i < q; i++) {
        int x;
        cin >> x;
        x--;
        cout << ans[x] << " ";
    }
}
