#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()

using namespace std;

template<class C> using vec = vector<C>;
using vi = vector<int>;
using pii = pair<int, int>;
using vpi = vec<pii>;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int n, tt;
    cin >> n >> tt;
    vi p(n);
    vi pot;
    vec<vi> g(n);
    for (int i = 1; i < n; i++) {
        int pr;
        cin >> pr;
        pr--;
        if (pr == 0) {
            pot.push_back(i);
        }
        g[pr].push_back(i);
    }
    vi tin(n), tout(n);
    int timer = 0;
    function<void(int)> dfs1 = [&](int v) {
        tin[v] = timer++;
        for (auto& to : g[v]) {
            dfs1(to);
        }
        tout[v] = timer++;
    };
    dfs1(0);
    auto is_anc = [&](int u, int v) -> bool {
        return tin[u] <= tin[v] && tout[u] >= tout[v];
    };
    vi s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    vi old_s = s;
    vi ans(n, n);
    for (int i : pot) {
        s = old_s;
        s[i] = 0;
        vi mn_pref = s;
        for (int j = 0; j < n; j++) {
            for (auto& to : g[j]) {
                mn_pref[to] = min(mn_pref[to], mn_pref[j]);
            }
        }
        vi cnt(n);
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                if (j != k && is_anc(j, k)) continue;
                if (mn_pref[k] >= mn_pref[j]) {
                    cnt[j]++;
                }
            }
        }
        for (int j = 0; j < n; j++) {
            ans[j] = min(ans[j], cnt[j]);
        }
    }
    while (tt--) {
        int u;
        cin >> u;
        u--;
        cout << ans[u] - 1 << ' ';
    }
}