#pragma GCC optimize("arch=skylake")
#pragma GCC optimize("Ofast,inline")

#include <bits/stdc++.h>

using namespace std;

//#define int int64_t
#define fi first
#define se second
mt19937 gen(time(0));

const int N = 3e5 + 12;
vector <int> g[N];
int a[N], ans[N], pr[N], sz[N], mx[N];

void dfs(int v) {
    sz[v] = 1;
    for(auto to : g[v]) {
        dfs(to);
        sz[v] += sz[to];
    }
    vector <pair<int,int>> c;
    for(auto to : g[v]) {
        c.push_back({a[to], to});
    }
    sort(c.begin(), c.end(), greater<>());
    int S = 1, m = 0;
    for(auto [x, to] : c) {
        ans[to] += S;
        mx[to] = m;
        m = max(m, sz[to]);
        S += sz[to];
    }
    return;
}
void dfs2(int v) {
    for(auto to : g[v]) {
        ans[to] += ans[v];
        mx[to] = max(mx[to], mx[v]);
        dfs2(to);
    }
    return;
}

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, qq;
    cin >> n >> qq;
    for(int i = 2; i <= n; ++i) {
        cin >> pr[i];
        g[pr[i]].push_back(i);
    }
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    dfs(1);
    dfs2(1);
    while(qq--) {
        int v;
        cin >> v;
        cout << ans[v] - mx[v] << ' ';
    }
    return 0;
}
