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

using namespace std;

typedef int ll;
typedef long double ld;

const ll inf = 1e9;
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;
vector<ll> first;

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, ll k1) {
    was[v] = 1;
    up[0][v] = p;
    for (int i = 1; i < 18; i++) up[i][v] = up[i - 1][up[i - 1][v]];
    t[v].first = t1;
    t1++;
    first[v] = k1;
    for (ll to: g[v]) {
        if (was[to] == 0) {
            h[to] = h[v] + 1;
            ll now1 = k1;
            if (now1 == -1) now1 = to;
            dfs(to, v, now1);
        }
    }
    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 = 17; i >= 0; i--) {
        if (ok(up[i][lca], v)) continue;
        lca = up[i][lca];
    }
    return up[0][lca];
}

vector<vector<ll>> c;

ll k_pr(ll v, ll col) {
    ll now = v;
    for(ll i1 = 0; i1 < c[col].size(); i1++) {
        ll i = c[col][i1];
        now = up[i][now];
    }
    return now;
}

vector<ll> lca1;

void dfs1(ll v, ll now) {
    lca1[v] = now;
    for(ll to : g[v]) {
        if (lca1[to] == -1) dfs1(to, now);
    }
    if (v != 0 && lca1[p[v]] == -1) dfs1(p[v], p[v]);
}

void solve() {
//    cout << (1LL << 11) << " +\n";
    cin >> n >> q;
    p.assign(n, 0);
    lca1.assign(n, 0);
    g.assign(n, {});
    s.assign(n, 0);
    was.assign(n, 0);
    lca1.assign(n, -1);
    h.assign(n, 0);
    t.assign(n, {0, 0});
    c.assign(n + 1, {});
    first.assign(n, 0);
    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});
    }
    vector<ll> ans = ind;
    vector<ll> col(n);
    vector<multiset<ll>> v1(n);
    for(int i = 0; i < n; i++) {
        for(ll to : g[i]) v1[i].insert(0);
    }
    ll now1 = 0, iter1 = 0;
    for(int i = 0; i < n; i++) {
        ll now = res[i];
        if (iter1 > ll(2 * 1e7)) {
            ans[now] = ind[now] - now1;
            continue;
        }
        while(1) {
            if (now != 0) v1[p[now]].erase(v1[p[now]].find(col[now]));
            col[now]++;
            if (now != 0 && v1[p[now]].size() != 0) ans[res[i]] = min(ans[res[i]], ind[res[i]] - (*v1[p[now]].rbegin()));
            if (now != 0) v1[p[now]].insert(col[now]);
            iter1++;
            if (now == 0) break;
            now = p[now];
        }
        now1 = ind[res[i]] - ans[res[i]];
    }
    for(int i = 0; i < q; i++) {
        ll v; cin >> v;
        v--;
        cout << ans[v] << " ";
    }
}

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;
}
