#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

typedef long long ll;
//#define int ll
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int N = 3e5 + 10;
const int C = 35;

int n, q, a[N], p[N], tout[N], tmr, ans[N], sz[N], dop[N], rt[N];
vector<int> g[N];
set<pii> child[N];

void calc_sz(int v) {
    sz[v] = 1;
    if(p[v] == 1) rt[v] = v;
    for(int to : g[v]) {
        rt[to] = rt[v];
        calc_sz(to);
        sz[v] += sz[to];
    }
}

void dfs(int v) {
    tout[v] = tmr++;
    if((int)child[v].size() == 0) return;
    auto [dx, mx] = *child[v].rbegin();
    child[v].erase({dx, mx});
    if((int)child[v].size() > (int)child[mx].size()) child[mx].swap(child[v]);
    for(auto p : child[v]) {
        if(p.Y != mx) child[mx].insert(p);
    }
    dfs(mx);
}

void solve() {
    cin >> n >> q;
    for(int i = 2; i <= n; ++i) {
        cin >> p[i];
        g[p[i]].pb(i);
    }
    for(int i = 1; i <= n; ++i) cin >> a[i];

    fill(ans, ans + n + 1, INF);

    calc_sz(1);
    vector<pii> ts;
    for(int i = 1; i <= n; ++i) {
        if(p[i] == 1) {
            ts.pb({a[i], i});
        }
    }

    sort(rall(ts));

    tmr = 0;
    for(int i = 1; i <= n; ++i) {
        child[i].clear();
        for(int to : g[i]) child[i].insert({a[to], to});
    }
    dfs(1);
    for(int i = 1; i <= n; ++i) ans[i] = tout[i];
    int mx = 0;
    for(auto [ai, i] : ts) {
        dop[i] = mx;
        mx = max(mx, sz[i]);
    }

    while(q--) {
        int v; cin >> v;
        cout << ans[v] - dop[rt[v]] << ' ';
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    auto start = clock();
#endif
    int ttt = 1;
    //cin >> ttt;
    while(ttt--) {
        solve();
    }
#ifdef LOCAL
    auto end = clock();
    cerr << "TIME: " << (end - start) << "ms" << '\n';
#endif
}