#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define int long long

const int MAX = 3e5 + 7;

vector<int> g[MAX];
int tin[MAX], tout[MAX];
int n, q;
int a[MAX];
int res[MAX];
int mn[MAX];
int up[MAX][20];

int timer = 0;

bool good(int aa, int b) {
    return (tin[aa] <= tin[b] && tout[aa] >= tout[b]);
}

void dfs1(int v, int p = 1) {
    tin[v] = ++timer;
    for (auto to : g[v]) {
        dfs1(to, v);
    }
    tout[v] = timer;
}

void solve() {
    cin >> n >> q;
    for (int i = 1; i <= n; i++) {
        res[i] = n + 1;
    }
    for (int i = 2; i <= n; i++) {
        int p;
        cin >> p;
        g[p].push_back(i);
    }
    dfs1(1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    mn[1] = 1e18;
    for (int i = 2; i <= n; i++) {
        int was = a[i];
        a[i] = 0;
        int ptr = 0;
        set<pair<int, int>> st;
        st.insert({a[1], 1});
        while ((int)(st.size())) {
            int v = (*--st.end()).second;
            st.erase(--st.end());
            res[v] = min(res[v], ptr++);
            for (auto to : g[v]) {
                st.insert({a[to], to});
            }
        }
        a[i] = was;
    }
    res[1] = 0;
    while (q--) {
        int v;
        cin >> v;
        cout << res[v] << ' ';
    }
}

int32_t main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tt = 1;
//     cin >> tt;
    while (tt--) {
        solve();
    }
}