#include <bits/stdc++.h>

using namespace std;

vector<vector<int>> g;
vector<int> s;
vector<vector<int>> pau;

void bfs(int ban) {
    set<pair<int, int>> q;
    if (ban == -1) {
        for (auto to : g[0]) {
            q.insert({s[to], to});
        }
    } else {
        q.insert({s[0], 0});
    }
    int ind = 0;
    while (!q.empty()) {
        auto cur = q.rbegin();
        int v = cur->second;
        pau[ban][v] = ind++;
        q.erase(*cur);
        for (auto to : g[v]) {
            if (ban != to) {
                q.insert({s[to], to});
                continue;
            }
            for (auto to2 : g[to]) {
                q.insert({s[to2], to2});
            }
        }
    }
}

void solve() {
    int n, q; cin >> n>> q;
    vector<int> p(n);
    s.resize(n);
    g.resize(n);
    pau.resize(n, vector<int> (n));
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        g[p[i]].push_back(i);
    }
    for (auto& i : s) cin >> i;
    for (int i = 0; i < n; i++) {
        pau[i][i] = 1e9;
        bfs(i);
    }
    /*for (int i = 0; i < n; i++) {
        for (int j = 0;  j < n; j++)  {
            cout << pau[i][j] << ' ';
        }
        cout << '\n';
    }*/
    while (q--) {
        int u; cin >> u; u--;
        int ans = 1e9;
        for (int i = 0; i < n; i++) {
            ans = min(ans, pau[i][u]);
        }
        cout << ans << ' ';
    }
    cout << '\n';
}

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    solve();
}
