#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll

const int inf = 1e9 + 7;

int N = 300'001, n;
vector<int> p(N);
vector<int> s(N);
vector<vector<int>> g(N);
vector<int> ans(N, inf);
vector<int> add(N);

void kek() {
    int day = 0;
    set<pair<int, int>> tmp;
    tmp.emplace(s[1], 1);
    multiset<int> added;
    for (int i = 1; i <= n; i++)
        added.insert(0);
    while (!tmp.empty()) {
        auto [_, v] = *tmp.rbegin();
        {
            int z = v;
            while (1) {
                added.erase(added.find(add[z]));
                add[z]++;
                if (z == 1)
                    break;
                z = p[z];
            }
        }
        tmp.erase(--tmp.end());
        ans[v] = day;
        if (!added.empty()) {
            ans[v] = day - *added.rbegin();
        }

        {
            int z = v;
            while (1) {
                added.insert(add[z]);
                if (z == 1)
                    break;
                z = p[z];
            }
        }
        for (auto u : g[v]) {
            tmp.emplace(s[u], u);
        }
        day++;
    }
}

void solve() {
    int q;
    cin >> n >> q;
    p[1] = 1;
    for (int i = 2; i <= n; i++) {
        cin >> p[i];
        g[p[i]].push_back(i);
    }
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
    }
    kek();
    for (int i = 0, v; i < q; i++) {
        cin >> v;
        cout << ans[v] << " ";
    }
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    while (t--)
        solve();
}