#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef long double ld;

const ll inf = 1e18;
const ll mod = 1e9 + 7;

ll n, q, t1 = 0;
vector<ll> p;
vector<vector<ll>> g;
vector<ll> s;
vector<ll> was;
vector<vector<ll>> up;
vector<pair<ll, ll>> t;
vector<ll> h;

ll ok(ll u, ll v) {
    return t[u].first <= t[v].first && t[u].second >= t[v].second;
}

void dfs(ll v, ll p) {
    was[v] = 1;
    up[0][v] = p;
    for (int i = 1; i < 20; i++) up[i][v] = up[i - 1][up[i - 1][v]];
    t[v].first = t1;
    t1++;
    for (ll to: g[v]) {
        if (was[to] == 0) {
            h[to] = h[v] + 1;
            dfs(to, v);
        }
    }
    t[v].second = t1;
    t1++;
}

ll lca(ll u, ll v) {
    if (ok(u, v)) return u;
    if (ok(v, u)) return v;
    ll lca = u;
    for (int i = 19; i >= 0; i--) {
        if (ok(up[i][lca], v)) continue;
        lca = up[i][lca];
    }
    return up[0][lca];
}

ll k_pr(ll v, ll col) {
    ll now = v;
    for(ll i = 0; i < 20; i++) {
        if ((col & (1LL << i)) != 0) {
            now = up[i][now];
        }
    }
    return now;
}

void solve() {
    cin >> n >> q;
    p.assign(n, 0);
    g.assign(n, {});
    s.assign(n, 0);
    h.assign(n, 0);
    t.assign(n, {0, 0});
    up.assign(20, vector<ll>(n));
    for(int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        g[p[i]].push_back(i);
    }
    for(int i = 0; i < n; i++) cin >> s[i];
    vector<ll> res;
    vector<ll> ind(n);
    multiset<pair<ll, ll>> s1;
    s1.insert({s[0], 0});
    while(!s1.empty()) {
        pair<ll, ll> p1 = *s1.rbegin();
        s1.erase(s1.find(p1));
        ll v = p1.second;
        ind[v] = res.size();
        res.push_back(v);
        for(ll to : g[v]) s1.insert({s[to], to});
    }
    for(int i = 0; i < q; i++) {
        ll x; cin >> x;
        x--;
        vector<ll> ans(n);
        for(int j = 0; j < ind[x]; j++) {
            if (ok(res[j], x)) continue;
            ll l = lca(x, res[j]);
            ll v1 = k_pr(res[j], h[j] - h[l] - 1);
            ans[v1]++;
        }
        cout << max(0LL, ind[x] - (*max_element(ans.begin(), ans.end())) - 1) << " ";
    }
}

int main() {
#ifdef KABANDJAN
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll ttt = 1;
//    cin >> ttt;
    while(ttt--) {
        solve();
    }
    return 0;
}
