#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define vi vector<ll>
#define vii vector<vi>
#define vip vector<pair<ll, ll>>
#define viip vector<vip>
#define endl '\n'
#define pb push_back
#define all(a) a.begin(), a.end()

const ll N = 3e5;

vii g(N);
vi ans(N, N - 1), s(N), p(N), gg(N);

set<pair<ll, ll>> st;
ll cn  =0; 

void dfs(ll v) {
    st.erase(gg[p[v]]);
    if (st.size()) {
        ans[v] = min(ans[v], cn - *(--st.end()));
    }
    gg[p[v]]++;
    st.insert(gg[p[v]]);
    cn++;
    for (ll to : g[v]) {
        st.insert({s[to], to});
    }
    if (!st.empty()) {
        auto [w, to] = *(--st.end());
        st.erase({w, to});
        if (v == 0) {
            p[to] = to;
        } else {
            p[to] = p[v];
        }
        dfs(to);
    }
}

void solve() {
    ll n, q;
    cin >> n >> q;
    for (ll i = 1; i < n; i++) {
        ll x;
        cin >> x;
        x--;
        g[x].pb(i);
    }
    for (ll i = 0; i < n; i++) {
        cin >> s[i];
    }
    dfs(0);
    while (q--) {
        ll v;
        cin >> v;
        v--;
        cout << ans[v] << " ";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}
