#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const ll mod = 1e9+7;

ll bpow(ll a, ll n) {
    ll res = 1;
    while (n) {
        res *= a;
        if (n & 1) a *= a;
        n /= 2;
    }
    return res;
}

const int N = 5e5+52;
const int M = 2e3+52;

int a[N];
vector<int> g[N];
bool used[N];
int d[N];
int n, q;

void dfs(int otm) {
    int dep = 0;
    used[otm] = 1;
    set<pair<int,int>> st;
    int v = 1;
    while(true) {
//        used[v] = 1;
        d[v] = min(dep++,d[v]);
        int mx = 0, mxu = 0;
        for (auto it : g[v]) {
            if (otm != it)st.insert({-a[it],it});
        }
//        for (auto u : ve) {
//            if (used[u] == 1) continue;
//            if (a[u] > mx) {
//                mx = a[u];
//                mxu = u;
//            }
//        }
        if (st.size() == 0) break;
        mxu = st.begin()->se;
        st.erase(st.begin());
        v = mxu;
    }
//    if (d[x] == -1) d[x] = n;
//    return d[x];
}

int main() {

    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> q;
//    return 0;
    for (int i = 2; i <= n; i++) {
        int p;
        cin >> p;
        g[p].pb(i);
    }

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

//    dfs(1);

    for (int i = 1; i <= n; i++) {
        d[i] = n + 1;
    }
    for (int i = 1; i <= n; i++) {
        dfs(i);
//        break;
    }
//    cout << "\n";
    while (q--) {
        int x;
        cin >> x;
        if (x == 1) {
            cout << "0 ";
            continue;
        }
//        int mn = 1e9;
//        for (int i = 1; i <= n; i++) {
//            if (x == i) continue;
//            mn = min(mn, dfs(x, i));
////            cout << dfs(x, 10) << " ";
//        }
//        mn = min(mn, dfs(x,n+1) - 1);
//        cout << "\n";
        cout << d[x] << " ";
//        break;
    }
    cout << "\n";
    return 0;
}
