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

const int MAXN = 303030;
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 cnt[MAXN];

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

    int n, 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];
        for (int u = 0; u < n; u++) {
            if (tin[u] <= tin[v] && tout[v] <= tout[u]) continue;
            ans[v] = min(ans[v], start[v] - cnt[u]);
        }

        while (v != -1) {
            cnt[v]++;
            v = prv[v];
        }
    }

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

    return 0;
}
