#include <bits/stdc++.h>
#define int long long

using namespace std;

const int inf = 2e9;

vector<vector<pair<int, int>>> g;
void solve() {
    int n, k; cin >> n >> k;
    vector<int> p(n), s(n);
    g.resize(n);
    for (int i = 1; i < n; ++i) {
        cin >> p[i]; --p[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        if (i != 0) {
            g[p[i]].push_back({-s[i], i});
        }
    }
    vector<int> ans(n, inf);
    for (int c = 0; c < n; ++c) {
        if (c == 0 || p[c] == 0) {

        } else {
            continue;
        }
        set<pair<int, int>> q;
        q.insert({s[0], 0});
        for (int i = 0; !q.empty(); ++i) {
            int v = q.begin()->second;
            q.erase(q.begin());
            ans[v] = min(ans[v], i);
            for (auto [f, u]: g[v]) {
                if (u != c) {
                    q.insert({f, u});
                }
            }
        }
    }
    for (int i = 0; i < k; ++i) {
        int x; cin >> x;
        cout << ans[x - 1] << ' ';
    }
    cout << '\n';
}

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