#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>;

constexpr int MAXN = 3e5 + 13;

vector<int> g[MAXN];
int a[MAXN], tin[MAXN], tout[MAXN], base[MAXN];

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

int curt = 0;

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

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

int ans;
vector<int> cnts[MAXN];

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

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

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

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

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

    dfs0(0);

    dfs5(0);

    for (int i = 0; i < q; ++i) {
        int cur;
        cin >> cur;
        --cur;
        ans = base[cur];
        dfs(0, cur);
        cout << ans << '\n';
    }
}
