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

#define all(x) x.begin(), x.end()
#define ff first
#define ss second

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using pii = pair<int, int>;

vector<vector<ll>> g;
vector<ll> a;
vector<ll> tin, tout;
vector<ll> base;

bool is_pred(ll u, ll v) {
    return tin[u] <= tin[v] && tout[u] >= tout[v];
}

ll curt = 0;

void dfs0(ll v) {
    tin[v] = curt++;
    for (ll child : g[v]) {
        dfs0(child);
    }
    tout[v] = curt++;
}

vector<ll> dp;

void dfs1(ll v, ll mx) {
    if (base[v] < mx) {
        ++dp[v];
    }
    for (ll child : g[v]) {
        dfs1(child, mx);
        dp[v] += dp[child];
    }
}

void dfs2(ll v, ll root, vector<ll>& vec) {
    vec.push_back(base[v]);
    for (ll child : g[v]) {
        dfs2(child, root, vec);
    }
}

ll ans;
vector<vector<ll>> cnts;

void dfs(ll v, ll cur) {
    for (ll child : g[v]) {
        if (is_pred(child, cur)) {
            dfs(child, cur);
        } else {
            ll cntless = lower_bound(all(cnts[child]), base[cur]) - cnts[child].begin();
            ans = min(ans, base[cur] - cntless);
        }
    }
}

void dfs5(ll v) {
    cnts[v].push_back(base[v]);
    for (ll child : g[v]) {
        dfs5(child);
        for (ll cnt : cnts[child]) {
            cnts[v].push_back(cnt);
        }
    }
    sort(all(cnts[v]));
}

signed main() {
    // freopen("inputc.txt", "r", stdin);
    ll n, q;
    cin >> n >> q;
    g.resize(n);
    a.resize(n);
    tin.resize(n);
    tout.resize(n);
    vector<ll> par(n);
    for (ll i = 1; i < n; ++i) {
        ll p;
        cin >> p;
        par[i] = p;
        --p;
        g[p].push_back(i);
    }
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
    }

    base.resize(n);
    set<pll, greater<pll>> s;
    s.emplace(a[0], 0);
    ll curdist = 0;
    while (!s.empty()) {
        ll v = s.begin()->second;
        s.erase(s.begin());
        base[v] = curdist;
        ++curdist;
        for (ll child : g[v]) {
            s.emplace(a[child], child);
        }
    }

    dfs0(0);

    cnts.resize(n);
    dfs5(0);

    for (ll i = 0; i < q; ++i) {
        ll cur;
        cin >> cur;
        --cur;
        ans = base[cur];
        dfs(0, cur);
        cout << ans << endl;//
    }
}
