#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef long long ll;

void solve();

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int tt = 1; //cin >> tt;
    while (tt--) {
        solve();
        cout << "\n";
    }
}

const int N = 3e5 + 1;

vector<int> g[N];
int tin[N], tout[N], s[N], t = 0;
vector<int> order;
set<pair<int, int> > c;

void dfs(int v) {
    tin[v] = t++;
    for (auto u : g[v]) dfs(u);
    tout[v] = t++;
}

bool ancestor(int a, int b) {
    return (tin[a] <= tin[b] && tout[b] <= tout[a]);
}

void find_order(int v) {
    order.push_back(v);

    for (auto u : g[v]) c.insert({-s[u], u});

    if (c.empty()) return;

    int best = (*c.begin()).S;
    c.erase(c.begin());

    find_order(best);
}

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

    dfs(0);
    find_order(0);
    vector<int> pos(n);
    for (int i = 0; i < n; i++) pos[order[i]] = i;

    while (q--) {
        int v; cin >> v; v--;
        if (v == 0) {
            cout << "0 ";
            continue;
        }
        int ans = pos[v];
        for (int i = 0; i < pos[v]; i++) {
            if (ancestor(order[i], v)) continue;
            int res = 0;
            for (int j = i; j < pos[v]; j++) {
                res += ancestor(order[i], order[j]);
            }
            ans = min(ans, pos[v] - res);
        }
        cout << ans << " ";
    }
}
