#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
constexpr char nl = '\n';

signed main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

    int n, q;
    cin >> n >> q;
    vi p(n);
    p[0] = -1;
    vvi g(n);
    for (int i = 1; i < n; ++i) {
        cin >> p[i];
        --p[i];
        g[p[i]].push_back(i);
    }
    vi s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    vi tin(n);
    int t = 0;
    priority_queue<pii> qu;
    qu.emplace(s[0], 0);
    while (!qu.empty()) {
        auto [w, v] = qu.top();
        qu.pop();
        tin[v] = t;
        for (int u: g[v]) {
            qu.emplace(s[u], u);
        }
        ++t;
    }
    vi seq(n);
    iota(seq.begin(), seq.end(), 0);
    sort(seq.begin(), seq.end(), [&tin](int i, int j) {
        return tin[i] < tin[j];
    });
    vi ban(n);
    vi ans = tin;
    for (int i = 0; i < n; ++i) {
        int v = seq[i];
        int j = v;
        set<int> bc;
        while (j != -1) {
            ++ban[j];
            bc.insert(j);
            j = p[j];
        }
        for (int k = 0; k < i; ++k) {
            int u = seq[k];
            if (bc.contains(u))
                continue;
            ans[v] = min(ans[v], tin[v] - ban[u]);
        }
    }
    for (int i = 0; i < q; ++i) {
        int v;
        cin >> v;
        cout << ans[--v] << ' ';
    }
}
