#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define fi first
#define se second
const ll inf = 1e17 + 7;

vector<ll> col, h, pos;
bool ok = 0;
ll cnt = 0, mx = 0;
ll dfs(ll v, ll need, vector<vector<ll>> &g) {
    if (v == need) {
        ok = 1;
        return 0;
    }
    ll cnt = 0;
    for(auto u : g[v]) {
        cnt += dfs(u, need, g);
    }
    if (pos[v] < pos[need]) {
        cnt++;
    }
    if (!ok) {
        mx = max(mx, cnt);
    }
}

void solve() {
    ll n, q;
    cin >> n >> q;
    h.resize(n);
    vector<vector<ll>> g(n);
    for(int i = 0; i < n - 1; ++i) {
        ll p;
        cin >> p;
        p--;
        g[p].push_back(i + 1);
    }
    vector<ll> s(n);
    for(int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    col.resize(n + 1);
    
    vector<ll> ts;
    multiset<pair<ll, ll>> ms;
    for(auto u : g[0]) {
        ms.insert({-s[u], u});
    }
    while(!ms.empty()) {
        auto x = *ms.begin();
        ms.erase(ms.begin());
        for(auto u : g[x.se]) {
            ms.insert({-s[u], u});
        }
        ts.push_back(x.se);
    }
    
    for(int i = 0; i < (int)ts.size(); ++i) {

        pos[ts[i]] = i + 1;

    }
    for(int i = 0; i < q; ++i) {

        ll v;
        cin >> v;
        v--;
        cout << pos[v] - dfs(0, v, g)<< ' ';
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll T = 1;
    //cin >> T;
    while(T--) {
        solve();
        cout << '\n';
    }
    return 0;
}
