#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

#define int int64_t
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ld long double
#define F first
#define S second


const int maxn = 3e5;
const int LOG = 30;
const int N = 2e3;
const ld eps = 1e-12;

vector<int> g[maxn];

int n, q;
int p[maxn];
int val[maxn];
int cur[maxn];
int used[maxn];
int h[maxn];
int V;

void go(int v) {
    p[v] = V;

    for(int u: g[v]) {
        h[u] = h[v] + 1;
        go(u);
    }
}



inline void solve() {
    cin >> n >> q;
    for (int i = 1; i < n; i++) {
        int x;
        cin >> x;
        x--;
        g[x].pb(i);
    }

    vector<pair<int, int>> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i].F;
        s[i].S = i;
    }


    for(int u: g[0]) {
        V = u;
        h[u] = 1;
        go(u);
        cur[u] = u;
        val[u] = 0;
    }

    h[0] = 0;

    sort(rall(s));


    vector<int> ans(n, n);
    set<pair<int, int>> st;

    for(int i = 0; i < n; i++) {
        if(s[i].S == 0) continue;
        int v = s[i].S;
        st.erase({val[p[v]], p[v]});
        ans[v] = h[v];
        if(st.size() > 1) {
            auto [x, y] = *st.rbegin();
            st.erase({x, y});
            ans[v] += st.rbegin()->F;
            st.insert({x, y});
        }

        used[v] = 1;

        while(cur[p[v]] != -1 && used[cur[p[v]]])  {
            if(g[cur[p[v]]].empty()) {
                cur[p[v]] = -1;
                break;
            }
            cur[p[v]] = g[cur[p[v]]][0];
            val[p[v]]++;
        }

        st.insert({val[p[v]], p[v]});
    }


    ans[0] = 0;

    while(q--) {
        int v;
        cin >> v;
        v--;
        cout << h[v] << ' ';
    }
    return;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int tt = 1;
    //cin >> tt;

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    while (tt--) {
        solve();
    }
    return 0;
}
