#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "inline")
#include <ext/pb_ds/assoc_container.hpp>

#define pii pair <int, int>
#define fi first
#define se second
#define pb push_back
#define int int64_t

using namespace std;
using namespace __gnu_pbds;

typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> oset;

mt19937 gen(time(0));

const int INF = 1e9;

struct dsu {
    vector <int> p, sz;
    void init (int n) {
        p.resize(n);
        sz.resize(n, 1);
        iota(p.begin(), p.end(), 0);
    }
    int get (int v) {
        if (p[v] == v) return v;
        return p[v] = get(p[v]);
    }
    void unite (int a, int b) {
        a = get(a);
        b = get(b);
        if (a == b) {
            return;
        }
        if (gen() & 1) {
            swap(a, b);
        }
        sz[a] += sz[b];
        p[b] = a;
    }
};

int32_t main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // LOCAL
    int n, q;
    cin >> n >> q;
    vector <int> p(n);
    vector <int> g[n];
    for (int i = 1; i < n; ++i) {
        cin >> p[i];
        p[i]--;
        g[p[i]].pb(i);
    }
    vector <int> s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    vector <int> v(q);
    for (int i = 0; i < q; ++i) {
        cin >> v[i];
        v[i]--;
    }
    vector <int> ans(n, n);
    function <void ()> go = [&] () {
        set <pii> st;
        vector <int> answer(n);
        st.insert({s[0], 0});
        int lvl = 0;
        while (!st.empty()) {
            pii x = *st.rbegin();
            st.erase(x);
            int i = x.se;
            answer[i] = lvl++;
            for (auto to : g[i]) {
                st.insert({s[to], to});
            }
        }
        for (int i = 0; i < n; ++i) {
            ans[i] = min(ans[i], answer[i]);
        }
    };
    go();
    vector <int> me(n), mn(n, INF);
    function <void (int, int)> dfs = [&] (int v, int gl) {
        me[v] = gl;
        for (auto to : g[v]) {
            mn[to] = min(mn[to], s[v]);
            if (gl == -1) dfs(to, to);
            else dfs(to, gl);
        }
    };
    dfs(0, -1);
    vector <int> who(n + 1);
    for (int i = 0; i < n; ++i) {
        who[s[i]] = i;
    }
    dsu d;
    d.init(n);
    multiset <int> all;
    all.insert(0);
    vector <bool> good(n);
    vector <int> qr[n + 1];
    for (int i = 1; i < n; ++i) {
        qr[mn[i]].pb(i);
    }
    for (int x = n; x >= 1; --x) {
        int v = who[x];
        if (v == 0) {
            for (int i : qr[x]) {
                int ld = me[i];
                if (good[ld]) {
                    all.erase(all.find(d.sz[d.get(ld)]));
                }
                ans[i] -= *all.rbegin();
                if (good[ld]) {
                    all.insert(d.sz[d.get(ld)]);
                }
            }
            continue;
        }
        int ld = me[v];
        if (good[ld]) {
            all.erase(all.find(d.sz[d.get(ld)]));
        }
        if (p[v] != 0 && s[p[v]] >= x) {
            d.unite(p[v], v);
        }
        for (auto to : g[v]) {
            if (s[to] >= x) {
                d.unite(to, v);
            }
        }
        if (s[ld] >= x) {
            good[ld] = 1;
            all.insert(d.sz[d.get(ld)]);
        }
        for (int i : qr[x]) {
            int ld = me[i];
            if (good[ld]) {
                all.erase(all.find(d.sz[d.get(ld)]));
            }
            ans[i] -= *all.rbegin();
            if (good[ld]) {
                all.insert(d.sz[d.get(ld)]);
            }
        }
    }
    for (auto i : v) {

        cout << ans[i] << ' ';
    }
}
