#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve();

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll q = 1;
    while (q--) {
        solve();
    }
}

const ll INF = 1e18;

vector<vector<pair<ll, ll>>> g;
vector<ll> cnt, mx;
vector<ll> sz;
void calc(ll v) {
    sz[v] = 1;
    for (auto [s, u] : g[v]) {
        calc(u);
        sz[v] += sz[u];
    }
}

void dfs(ll v) {
    ll sm = 0;
    ll m = 0;
    for (auto [s, u] : g[v]) {
        cnt[u] = cnt[v] + sm + 1;
        mx[u] = max(mx[v], m);
        dfs(u);
        sm += sz[u];
        m = max(m, sz[u]);
    }
}


void solve() {
    ll n, q;
    cin >> n >> q;
    vector<ll> p(n);
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }
    vector<ll> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    g.resize(n);
    for (int i = 1; i < n; i++) {
        g[p[i]].emplace_back(s[i], i);
    }
    for (int i = 0; i < n; i++) {
        sort(g[i].rbegin(), g[i].rend());
    }
    sz.resize(n);
    cnt.resize(n), mx.resize(n);
    dfs(0);
    for (int i = 0; i < q; i++) {
        ll v;
        cin >> v;
        v--;
        cout << cnt[v] - mx[v] << ' ';
    }
} 