#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define int long long

using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
const int INF = 1e18;
const int MOD = 1e9 + 7;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

vector<vector<int>> g;
vector<bool> vis;
vector<int> ans;
vector<int> s;

void dfs(int v, int tnow = 0) {
    ans[v] = tnow;
    vis[v] = true;
    pair<int, int> now = {-1, -1};
    for (int u : g[v]) {
        if (vis[u]) continue;
        now = max(now, {s[u], u});
    }
    if (now.second == -1) return;
    int newv = now.second;
    for (int u : g[v]) {
        if (vis[u] || u == newv) continue;
        g[newv].push_back(u);
    }
    dfs(newv, tnow + 1);
}

vector<bool> onway;
int ansdel = 0;
ordered_set dfs2(int v, int t, int par = -1) {
    if (ans[v] >= t) return {};
    ordered_set now;
    if (!onway[v]) now.insert(ans[v]);
    for (int u : g[v]) {
        if (u == par) continue;
        ordered_set other = dfs2(u, t, v);
        if (onway[v] && !onway[u]) ansdel = max(ansdel, (int)other.order_of_key(t));
        if (other.size() > now.size()) swap(other, now);
        for (int i : other) now.insert(i);
    }
    return now;
}

void solve() {
    int n, q;
    cin >> n >> q;
    g.resize(n);
    vector<int> par(n);
    for (int i = 1; i < n; ++i) {
        int v;
        cin >> v;
        --v;
        g[i].push_back(v);
        g[v].push_back(i);
        par[i] = v;
    }
    s.resize(n);
    for (int i = 0; i < n; ++i) cin >> s[i];
    vis.resize(n);
    ans.resize(n);
    vector<vector<int>> gwas = g;
    dfs(0);
    g = gwas;
    while (q--) {
        int v;
        cin >> v;
        --v;
        onway.assign(n, false);
        int now = v;
        while (now) {
            onway[now] = true;
            now = par[now];
        }
        onway[0] = true;
        ansdel = 0;
        dfs2(0, ans[v]);
        cout << ans[v] - ansdel << " ";
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}
