#include <bits/stdc++.h>

using ll = long long;

using namespace std;

#define int ll

vector<int> p;
vector<set<pair<int, int>>> g;
vector<set<pair<int, int>>> g2;
vector<int> s;
vector<int> order;
vector<int> ans;
vector<int> sz;
vector<int> root;
int n;

void get_ord() {
    int cur = 0;
    while (order.size() < n) {
        order.push_back(cur);
        if (g2[cur].size()) {
            int nw = g2[cur].rbegin()->second;
            g2[cur].erase(--g2[cur].end());
            if (g2[cur].size() > g2[nw].size()) {
                swap(g2[cur], g2[nw]);
            }
            for (auto x : g2[cur]) {
                g2[nw].insert(x);
            }
            cur = nw;
        }
    }
}

void get_root(int v, int r) {
    root[v] = r;
    for (auto [kek, u] : g[v]) {
        get_root(u, r);
    }
}

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int q;
    cin >> n >> q;
    p.resize(n);
    g.resize(n);
    s.resize(n);
    g2.resize(n);
    sz.resize(n);
    root.resize(n);

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

    for (int i = 0; i < n; i++) {
        g2[i].clear();
        for (auto [kek, j] : g[i]) {
            g2[i].insert({s[j], j});
        }
    }

    ans.resize(n);

    get_ord();
    for (int i = 0; i < n; i++) {
        ans[order[i]] = i;
    }
    vector<int> lol(n);

    vector<int> roots;
    set<pair<int, int>> st;
    for (auto [kek, v] : g[0]) {
        roots.push_back(v);
        get_root(v, v);
        st.insert({0, v});
    }

    for (int i = 1; i < n; i++) {
        if (st.size() > 1) {
            auto it = st.rbegin();
            if (it->second == root[order[i]]) {
                it++;
            }
            lol[order[i]] = it->first;
        }
        st.erase({sz[root[order[i]]], root[order[i]]});
        sz[root[order[i]]]++;
        st.insert({sz[root[order[i]]], root[order[i]]});
    }

    while (q--) {
        int v;
        cin >> v;
        v--;
        cout << ans[v] - lol[v] << " ";
    }

    cout << "\n";
    return 0;
}