#ifndef LOCAL
#pragma GCC optimize("Ofast,unroll-loops")
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define X first
#define Y second

const int MAXN = 3e5 + 30;

int n, L;

int s[MAXN], tin[MAXN], tout[MAXN], cnt[MAXN];
vector<vector<int>> g;
vector<int> tour;
vector<vector<int>> bu;

int t = 0;

void dfs(int u, int p)
{
    bu[u][0] = p;
    for (int i = 1; i <= L; i++)
        bu[u][i] = bu[bu[u][i - 1]][i - 1];
    tin[u] = t++;
    for (int v : g[u])
        dfs(v, u);
    tout[u] = t;
}

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

int lca(int u, int v)
{
    for (int i = L; i >= 0; i--)
        if (!is_anc(bu[u][i], v))
            u = bu[u][i];
    return u;
}

void solve()
{
    int q;
    cin >> n >> q;
    g.resize(n);
    L = __lg(n);
    bu.resize(n, vector<int>(L + 1, 0));
    for (int i = 0; i < n - 1; i++) {
        int x;
        cin >> x;
        x--;
        g[x].push_back(i + 1);
    }
    dfs(0, 0);
    for (int i = 0; i < n; i++)
        cin >> s[i];
    priority_queue<pair<int, int>> que;
    vector<int> pos(n);
    tour.push_back(0);
    pos[0] = 0;
    for (int i : g[0])
        que.push({ s[i], i });
    while (que.size()) {
        auto [val, x] = que.top();
        que.pop();
        pos[x] = tour.size();
        tour.push_back(x);
        for (int i : g[x])
            que.push({ s[i], i });
    }
    for (int qs = 0; qs < q; qs++) {
        int u;
        cin >> u;
        u--;
        int ans = pos[u];
        fill(cnt, cnt + n, 0);
        for (int i = 0; i < pos[u]; i++) {
            if (is_anc(tour[i], u))
                continue;
            int lc = lca(tour[i], u);
            cnt[lc]++;
        }
        cout << ans - *max_element(cnt, cnt + n) << ' ';
    }
    cout << '\n';
}

signed main()
{
#ifdef LOCAL
    freopen("TEST", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int ttt = 1;
    // cin >> ttt;
    while (ttt--)
        solve();
}
