#ifdef ONPC
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i128 = __int128_t;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937_64 rng(chrono::steady_clock().now().time_since_epoch().count());

ll segtree[1 << 20] = {};
ll lz[1 << 20] = {};

void push(int x, int l, int r) {
    if (lz[x] == 0) return;

    if (l + 1 != r) {
        lz[2 * x + 1] += lz[x];
        lz[2 * x + 2] += lz[x];
    }

    segtree[x] += lz[x];
    lz[x] = 0;
}

ll get(int lq, int rq, int x, int l, int r) {
    if (rq <= l || r <= lq) return 0;
    push(x, l, r);
    if (lq <= l && r <= rq) return segtree[x];

    int m = (l + r) / 2;
    return max(get(lq, rq, 2 * x + 1, l, m), get(lq, rq, 2 * x + 2, m, r));
}

void update(int lq, int rq, int v, int x, int l, int r) {
    if (lq <= l && r <= rq) {
        lz[x] += v;
        push(x, l, r);
        return;
    }
    push(x, l, r);
    if (rq <= l || r <= lq) return;

    int m = (l + r) / 2;
    update(lq, rq, v, 2 * x + 1, l, m);
    update(lq, rq, v, 2 * x + 2, m, r);
    segtree[x] = max(segtree[2 * x + 1], segtree[2 * x + 2]);
}

const int MAXN = 303030;
const int INF = 1e6;
int prv[MAXN];
vector<int> g[MAXN];
int ans[MAXN];

int s[MAXN];

int start[MAXN], id[MAXN];

int head[MAXN];
int sz[MAXN];
int tin[MAXN], tout[MAXN];

void precalc(int v) {
    sz[v] = 1;
    int mx = -1;
    for (int i = 0; i < g[v].size(); i++) {
        int u = g[v][i];
        precalc(u);
        sz[v] += sz[u];
        if (mx == -1 || sz[mx] < sz[u]) mx = i;
    }

    if (mx != -1) swap(g[v][0], g[v][mx]);
}

int timer = 0;
void hld(int v) {
    tin[v] = timer++;
    if (!g[v].empty()) head[g[v][0]] = head[v];
    for (auto u : g[v]) hld(u);
    tout[v] = timer;
}

int n;
void path_update(int v, int add) {
    while (v != -1) {
        update(tin[head[v]], tin[v] + 1, add, 0, 0, n);
        v = prv[head[v]];
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int q;
    cin >> n >> q;
    prv[0] = -1;
    for (int i = 1; i < n; i++) {
        cin >> prv[i], prv[i]--;
        g[prv[i]].push_back(i);
    }
    for (int i = 0; i < n; i++) cin >> s[i];

    precalc(0);
    iota(head, head + n, 0);
    hld(0);

    int cur = 0;
    priority_queue<array<int, 2>> pq;
    pq.push({0, 0});
    while (!pq.empty()) {
        auto [_, v] = pq.top();
        pq.pop();
        start[v] = cur++;
        id[start[v]] = v;
        for (auto u : g[v]) pq.push({s[u], u});
    }

    for (int i = 0; i < n; i++) {
        int v = id[i];
        ans[v] = start[v];
        path_update(v, -INF);
        ans[v] = min<ll>(ans[v], start[v] - get(0, n, 0, 0, n));
        path_update(v, INF);

        path_update(v, 1);
    }

    for (int i = 0; i < q; i++) {
        int v;
        cin >> v;
        cout << ans[v - 1] << " \n"[i + 1 == q];
    }

    return 0;
}
