#include <bits/stdc++.h>
using namespace std;

vector<vector<int>> G;
vector<pair<int, int>> ans;
vector<int> pr;
vector<int> sz;
vector<multiset<int>> maxi;

void dfs(int v, int p) {
    sz[v] = 1;
    for (auto u : G[v]) {
        if (u != p) {
            dfs(u, v);
            pr[u] = v;
            sz[v] += sz[u];
            maxi[v].insert(-sz[u]);
        }
    }
}

void find_ans(int v) {
    if (pr[v] == -1) {
        return;
    }
    int max_s = 0;
    if (*(maxi[pr[v]].begin()) == -sz[v] && (int)maxi[pr[v]].size() != 1) {
        max_s = max(max_s, -*(++maxi[pr[v]].begin()));
    } else if (*(maxi[pr[v]].begin()) != -sz[v]) {
        max_s = max(max_s, -*(maxi[pr[v]].begin()));
    }
    int t = pr[v];
    while (pr[t] != -1) {
        if (*(maxi[pr[t]].begin()) == -sz[t] && (int)maxi[pr[t]].size() != 1) {
            max_s = max(max_s, -*(++maxi[pr[t]].begin()));
        } else if (*maxi[pr[t]].begin() != -sz[t]) {
            max_s = max(max_s, -*(maxi[pr[t]].begin()));
        }
        t = pr[t];
    }
    ans[v] = {min(ans[t].second + sz[t] - max_s - sz[v], ans[t].first + sz[t] - sz[v]), ans[t].second + sz[t] - sz[v]};
    maxi[pr[v]].erase(maxi[pr[v]].find(-sz[v]));
    t = pr[v];
    while (pr[t] != -1) {
        maxi[pr[t]].erase(maxi[pr[t]].find(-sz[t]));
        sz[t] -= sz[v];
        maxi[pr[t]].insert(-sz[t]);
        t = pr[t];
    }
    sz[t] -= sz[v];
    pr[v] = -1;
}

int main() {
    int n, q;
    cin >> n >> q;
    G.resize(n);
    ans.resize(n);
    pr.resize(n, -1);
    maxi.resize(n);
    sz.resize(n, 0);
    int f;
    for (int i = 1; i < n; i++) {
        cin >> f;
        f--;
        G[f].push_back(i);
        G[i].push_back(f);
    }
    dfs(0, 0);
    ans[0] = {0, 0};
    vector<pair<int, int>> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i].first;
        s[i].second = i;
    }
    sort(s.begin(), s.end());
    for (auto u : s) {
        find_ans(u.second);
    }
    int v;
    for (int i = 0; i < q; i++) {
        cin >> v;
        v--;
        cout << ans[v].first << " ";
    }
    return 0;
}



