#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector <vector <int>> g;
vector <int> s, vec;
int n;

void get_ans(int u, vector <int> &ans) {
    int last = s[u];
    s[u] = 0;
    priority_queue <pair <int, int>, vector <pair <int, int>>> q;
    q.emplace(s[0], 0);
    vector <int> used(n, 0);
    int col = 0;
    while (!q.empty()) {
        int v = q.top().second;
        used[v] = 1;
        q.pop();
        ans[v] = min(ans[v], col);
        for (auto &to : g[v]) {
            if (used[to]) continue;
            q.emplace(s[to], to);
        }
        col++;
    }
    s[u] = last;
}

void solve() {
    int q; cin >> n >> q;
    g.assign(n, {});
    s.assign(n, 0);
    vec.assign(q, 0);
    for (int i = 1; i < n; i++) {
        int x; cin >> x;
        x--;
        g[i].emplace_back(x);
        g[x].emplace_back(i);
    }
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 0; i < q; i++) {
        cin >> vec[i];
        vec[i]--;
    }
    vector <int> ans(n, n + 2);
    for (int i = 0; i < n; i++) {
        get_ans(i, ans);
    }
    for (auto &u : vec) {
        cout << ans[u] << " ";
    }
    cout << endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int test = 1;
    for (int i = 0; i < test; i++) {
        solve();
    }
}
