#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void dfs(ll v, vector<vector<ll>> &g, vector<ll> &ans, ll x) {
    ans[v] = x;
    for (ll u : g[v]) {
        dfs(u, g, ans, x + 1);
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, q;
    cin >> n >> q;
    vector<vector<ll>> g(n);
    for (ll i = 1; i < n; i++) {
        ll p;
        cin >> p;
        p--;
        g[p].push_back(i);
    }
    vector<ll> s(n);
    for (ll &i : s) cin >> i;
    vector<ll> ans(n);
    dfs(0, g, ans, 0);
    vector<pair<ll, ll>> b;
    for (ll i : g[0]) {
        b.emplace_back(s[i], i);
    }
    sort(b.rbegin(), b.rend());
    for (ll i = 0; i < (ll) b.size(); i++) {
        ans[b[i].second] = max(1ll, i);
    }
    while (q--) {
        ll x;
        cin >> x;
        x--;
        cout << ans[x] << ' ';
    }
    cout << '\n';
}
