#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

struct node {
    int mx, push;
};  

struct segtree {
    int n;
    vector<int> a;
    vector<node> t;
    segtree() = default;
    segtree(int n_, vector<int> a_) {
        n = n_; a = a_;
        t.resize(4 * n);
        build(1, 0, n);
    }

    void build(int v, int tl, int tr) {
        if (tl + 1 == tr) {
            t[v] = {a[tl], 0};
            return;
        }
        int tm = (tl + tr) / 2;
        build(v << 1, tl, tm); build(v << 1 | 1, tm, tr);
        t[v] = {max(t[v << 1].mx, t[v << 1 | 1].mx), 0};
    }

    void push(int v) {
        if (t[v].push) {
            t[v].mx += t[v].push;
            t[v << 1].push += t[v].push;
            t[v << 1 | 1].push += t[v].push;
            t[v].push = 0;
        }
    }

    void pull(int v) {
        t[v].mx = max(t[v << 1].mx + t[v << 1].push, t[v << 1 | 1].mx + t[v << 1 | 1].push);
    }

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

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

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

    vector<int> siz(n);
    auto dfs = [&](int v, auto&&self) -> void {
        siz[v] = 1;
        int bps = 0, cr = 0;
        for (int u : g[v]) {
            self(u, self);
            if (siz[u] > siz[g[v][bps]]) bps = cr;
            cr++;
        }
        if (!g[v].empty()) swap(g[v][bps], g[v][0]);
    };
    dfs(0, dfs);

    vector<int> tin(n), nxt(n, 0);
    int tim = 0;
    auto dfs2 = [&](int v, auto&&self) -> void {
        tin[v] = tim++;
        for (int u : g[v]) {
            nxt[u] = (g[v][0] == u ? nxt[v] : u);
            self(u, self);
        }
    };
    dfs2(0, dfs2);
    segtree sg(n, vector<int>(n, 0));

    vector<int> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];
    vector<int> ans(n), seq;
    set<pair<int, int>> cands = {{s[0], 0}};
    for (int i = 0; i < n; i++) {
        auto it = cands.rbegin();
        seq.pb((*it).second);
        int vt = (*it).second;
        cands.erase((*it));
        for (int u : g[vt]) {
            cands.insert({s[u], u});
        }
    }
    vector<int> pos(n);
    for (int i = 0; i < n; i++) pos[seq[i]] = i;

    auto add = [&](int v, int x) {
        while (v != -1) {
            sg.upd(1, 0, n, tin[nxt[v]], tin[v] + 1, x);
            v = p[nxt[v]];
        }
    };  

    for (int i = 0; i < n; i++) {
        add(seq[i], -n);
        ans[seq[i]] = i - sg.get(1, 0, n, 0, n);
        add(seq[i], n + 1);
    }   

    while (q--) {
        int v; cin >> v;
        v--;
        cout << ans[v] << ' ';
    }
    cout << '\n';
}

signed main() {
    int tt = 1;
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        cin >> tt;
    #else
        cin.tie(0)->sync_with_stdio(false);
    #endif  

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

    return 0;
}