#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 pr[MAX];
int a[MAX];
int res[MAX];
int mn[MAX];
int up[MAX][20];

int sz[MAX];
int hld[MAX];
int timer = 0;

void dfssz(int v) {
    sz[v] = 1;
    for (auto to : g[v]) {
        dfssz(to);
        sz[v] += sz[to];
    }
}

void dfs(int v) {
    sort(g[v].begin(), g[v].end(), [&](auto p1, auto p2) {
        return sz[p1] > sz[p2];
    });
    tin[v] = ++timer;
    for (auto to : g[v]) {
        if (to == g[v][0]) {
            hld[to] = hld[v];
        } else {
            hld[to] = to;
        }
        dfs(to);
    }
}

int t[MAX * 4];
int lazy[MAX * 4];

void push(int v, int tl, int tr) {
    if (tl == tr || !lazy[v]) return;
    t[v * 2] += lazy[v];
    lazy[v * 2] += lazy[v];
    t[v * 2 + 1] += lazy[v];
    lazy[v * 2 + 1] += lazy[v];
    lazy[v] = 0;
}

void upd(int v, int tl, int tr, int l, int r) {
    if (l > tr || r < tl) return;
    if (l <= tl && tr <= r) {
        t[v]++;
        lazy[v]++;
        return;
    }
    push(v, tl, tr);
    int tm = (tl + tr) / 2;
    upd(v * 2, tl, tm, l, r);
    upd(v * 2 + 1, tm + 1, tr, l, r);
    t[v] = max(t[v * 2], t[v * 2 + 1]);
}

int get(int v, int tl, int tr, int l, int r) {
    if (l > tr || r < tl) return 0;
    if (l <= tl && tr <= r) {
        return t[v];
    }
    push(v, tl, tr);
    int tm = (tl + tr) / 2;
    return max(get(v * 2, tl, tm, l, r), get(v * 2 + 1, tm + 1, tr, l, r));
}

void upd(int v) {
    while (v) {
        upd(1, 1, n, tin[hld[v]], tin[v]);
        v = pr[hld[v]];
    }
}

int get(int v) {
    int ret = 0;
    vector<pair<int, int>> st;
    while (v) {
        st.push_back({tin[hld[v]], tin[v]});
        v = pr[hld[v]];
    }
    sort(st.begin(), st.end());
    if ((int)(st.size()) && st[0].first > 1) {
        ret = max(ret, get(1, 1, n, 1, st[0].first - 1));
    }
    if ((int)(st.size()) && st.back().second < n) {
        ret = max(ret, get(1, 1, n, st.back().second + 1, n));
    }
    for (int i = 1; i < (int)(st.size()); i++) {
        if (st[i - 1].second + 1 <= st[i].first - 1) {
            ret = max(ret, get(1, 1, n, st[i - 1].second + 1, st[i].first - 1));
        }
    }
    return ret;
}

int rq[MAX];
bool need[MAX];

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;
        pr[i] = p;
        g[p].push_back(i);
    }
    dfssz(1);
    hld[1] = 1;
    dfs(1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    res[1] = 0;
    for (int i = 1; i <= q; i++) {
        cin >> rq[i];
        need[rq[i]] = 1;
    }
    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());
        upd(v);
        int del = 0;
        int now = v;
        if (need[v]) {
            res[v] = min(res[v], ptr - get(v));
        }
        ptr++;
        for (auto to : g[v]) {
            st.insert({a[to], to});
        }
    }
    for (int i = 1; i <= q; i++) {
        cout << res[rq[i]] << ' ';
    }
}

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