#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
#define ll long long

using namespace std;
//using namespace __gnu_pbds;


ll n, q;
vector<ll> s, v, pos, ans, color, pp;
vector<vector<ll>> a;
vector<bool> used;

void input() {
    cin >> n >> q;
    pp = {-1};
    a.resize(n);
    for (ll i = 0; i < n - 1; i++) {
        ll p;
        cin >> p;
        pp.push_back(p - 1);
        a[p - 1].push_back(i + 1);
        a[i + 1].push_back(p - 1);
    }
    s.resize(n);
    v.resize(q);
    for (ll i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (ll i = 0; i < q; i++) {
        cin >> v[i];
    }
}

void dfs(ll u, ll cl) {
    used[u] = true;
    color[u] = cl;
    for (ll i = 0; i < a[u].size(); i++) {
        if (!used[a[u][i]]) {
            dfs(a[u][i], cl);
        }
    }
}

void solve() {
    pos.resize(n);
    pos[0] = 1;
    set<pair<ll, ll>> ses;
    used.assign(n, false);
    used[0] = true;
    for (ll i = 0; i < a[0].size(); i++) {
        used[a[0][i]] = true;
        ses.insert({-s[a[0][i]], a[0][i]});
    }
    ll cnt = 1;
    vector<ll> order = {0};
    while (ses.size() > 0) {
        cnt++;
        ll u = ses.begin() -> second;
        pos[u] = cnt;
        order.push_back(u);
        ses.erase(ses.begin());
        for (ll i = 0; i < a[u].size(); i++) {
            if (!used[a[u][i]]) {
                used[a[u][i]] = true;
                ses.insert({-s[a[u][i]], a[u][i]});
            }
        }
    }
    multiset<ll> lol, lolmin;
    vector<ll> sum(n, 0);
    sum[0] = 1;
    lol.insert(-1);
    lolmin.insert(1);
    ans.resize(n);
    used.assign(n, false);
    for (ll i = 1; i < n; i++) {
        ll tk = order[i];
        ll r = tk;
        vector<ll> preds;
        while (true) {
            r = pp[r];
            if (r == -1) {
                break;
            }
            preds.push_back(r);
        }
        for (ll j = 0; j < preds.size(); j++) {
            auto t = lol.find(-sum[preds[j]]);
            if (t != lol.end()) {
                lol.erase(t);
                lolmin.erase(lolmin.find(sum[preds[j]]));
            }
        }
        ll maxim = 0;
        if (lol.size() > 0) {
            maxim = -(*lol.begin());
        }
        ans[tk] = i - maxim;
        for (ll j = 0; j < preds.size(); j++) {
            lol.insert(-(++sum[preds[j]]));
            lolmin.insert(sum[preds[j]]);
        }
        sum[tk]++;
        lol.insert(-1);
        lolmin.insert(1);
        if (lolmin.size() > 100) {
            ll minim = *lolmin.begin();
            lolmin.erase(lolmin.begin());
            lol.erase(lol.find(-minim));
        }
    }
}

void output() {
    for (ll i = 0; i < q; i++) {
        cout << ans[v[i] - 1] << " ";
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    input();
    solve();
    output();
    return 0;
}
