#include <bits/stdc++.h>

using namespace std;
#define int long long

vector<vector<int>> g;

vector<int> col, p, ans;

void dfs(int v) {
    if (p[v] == 0) {
        col[v] = v;
        ans[v] = 2;
    } else {
        col[v] = col[p[v]];
        ans[v] = ans[p[v]] + 1;
    }
    for (auto to: g[v]) {
        dfs(to);
    }
}

signed main() {
    int n, q;
    cin >> n >> q;
    p.resize(n);
    ans.resize(n);
    g.resize(n), col.resize(n);
    for (int i = 1; i < n; ++i) {
        cin >> p[i];
        p[i]--;
        g[p[i]].push_back(i);
    }
    vector<int> s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    dfs(0);
    int curr = 0;
    vector<int> in(n), u(q);
    for (int i = 0; i < q; ++i) {
        cin >> u[i];
        in[u[i] - 1] = 1;
    }
    set<pair<int, int>> sn;
    vector<int> cnt(n), ans(n);
    ans[0] = 1;
    for (int i = 0; i < n - 1; ++i) {
        int ind = -1, mx = 0;
        for (auto to: g[curr]) {
            if (s[to] > mx) {
                mx = s[to];
                ind = to;
            }
        }
        for (auto to: g[curr]) {
            if (to != ind) {
                g[ind].push_back(to);
            }
        }
        curr = ind;
        cnt[col[curr]]++;
        if (in[curr]) {
            if (sn.empty()) {
                ans[curr] = 2;
                sn.insert({1, curr});
                continue;
            }
            auto to = *sn.rbegin();
            if (to.second != col[curr]) {
                ans[curr] = i + 2 - to.first;
            } else {
                sn.erase(to);
                if (sn.empty()) {
                    ans[curr] = i + 2;
                } else {
                    auto to1 = *sn.rbegin();
                    ans[curr] = i + 2 - to1.first;
                }
                sn.insert(to);
            }
        }
        if (p[curr] == 0) {
            sn.insert({1, curr});
        } else {
            sn.erase({cnt[col[curr]] - 1, col[curr]});
            sn.insert({cnt[col[curr]], col[curr]});
        }
    }
    for (auto to: u) {
        cout << ans[to - 1] - 1 << " ";
    }
    return 0;
}
