#include <bits/stdc++.h>

using namespace std;
using ll = long long;

vector<int> tree, pushed;

void push(int v, int tl, int tr) {
    if (tl + 1 == tr) {
        pushed[v] = 0;
        return;
    }
    pushed[2 * v + 1] += pushed[v];
    pushed[2 * v + 2] += pushed[v];
    tree[2 * v + 1] += pushed[v];
    tree[2 * v + 2] += pushed[v];
    pushed[v] = 0;
}

void update(int v, int tl, int tr, int ql, int qr, int x) {
    if (qr <= tl || tr <= ql) {
        return;
    }
    if (ql <= tl && tr <= qr) {
        pushed[v] += x;
        tree[v] += x;
        return;
    }
    push(v, tl, tr);
    int tm = (tl + tr) >> 1;
    update(2 * v + 1, tl, tm, ql, qr, x);
    update(2 * v + 2, tm, tr, ql, qr, x);
    tree[v] = max(tree[2 * v + 1], tree[2 * v + 2]);
}

int main() {
#ifdef home
    freopen("f.in", "r", stdin);
    freopen("f.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    vector<int> par(n, -1);
    vector<vector<int>> g(n);
    for (int v = 1; v < n; v++) {
        int u;
        cin >> u;
        u--;
        par[v] = u;
        g[u].emplace_back(v);
    }
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    vector<int> h(n), head(n), sizes(n), where(n);
    vector<int> tour;
    auto cdfs = [&](auto &&self, int v) -> int {
        sizes[v] = 1;
        for (auto &u: g[v]) {
            sizes[v] += self(self, u);
        }
        return sizes[v];
    };
    cdfs(cdfs, 0);
    auto dfs = [&](auto &&self, int v) -> void {
        ranges::sort(g[v], [&](int foo, int bar) {
            return sizes[foo] > sizes[bar];
        });
        tour.emplace_back(v);
        where[v] = (int) tour.size() - 1;
        bool heavy = true;
        for (auto &u: g[v]) {
            h[u] = h[v] + 1;
            if (heavy) {
                head[u] = head[v];
                heavy = false;
            } else {
                head[u] = u;
            }
            self(self, u);
        }
    };
    dfs(dfs, 0);
    tree.resize(4 * n, 0);
    pushed.resize(4 * n, 0);
    vector<int> order;
    set<pair<int, int>> flex;
    for (auto &v: g[0]) {
        flex.emplace(s[v], v);
    }
    for (int root = 0; root != -1;) {
        order.emplace_back(root);
        if (flex.empty()) {
            break;
        }
        int cand = flex.rbegin()->second;
        flex.erase(*flex.rbegin());
        for (auto &v: g[cand]) {
            flex.emplace(s[v], v);
        }
        swap(cand, root);
    }
    vector<int> ans(n, n + 1);
    for (int i = 0; i < n; i++) {
        ans[order[i]] = i;
    }
    auto upd = [&](int v, int u, int x) -> void {
        while (head[v] != head[u]) {
            if (h[head[v]] > h[head[u]]) {
                swap(v, u);
            }
            assert(where[head[u]] < where[u] + 1);
            update(0, 0, n, where[head[u]], where[u] + 1, x);
            u = par[head[u]];
        }
        int l = where[v], r = where[u];
        if (l > r) {
            swap(l, r);
        }
        update(0, 0, n, l, r + 1, x);
    };
    for (int i = 0; i < n; i++) {
        int v = order[i];
        upd(v, 0, -(2 * n));
        ans[v] = min(ans[v], i - tree[0]);
        upd(v, 0, 2 * n + 1);
    }
    while (q--) {
        int v;
        cin >> v;
        v--;
        cout << ans[v] << ' ';
    }
    cout << '\n';
    return 0;
}
