#include <bits/stdc++.h>

#ifndef LOCAL
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

const int maxn = 3e5;
vector<int> g[maxn];
int s[maxn];
int ans[maxn];

void calc(int v) {
    set<pair<int, int>> ch;
    ch.insert({0, 0});
    int tk = 0;
    while(!ch.empty()) {
        auto res = *ch.rbegin();
        ch.erase(res);
        int u = res.second;
        ans[u] = min(ans[u], tk++);
        for (int i: g[u]) {
            if(i != v)
                ch.emplace(s[i], i);
            else 
                ch.emplace(0, i);
        }
    }
}

void solve() {
    fill(ans, ans + maxn, 1e9);
    int n, q;
    cin >> n >> q;
    vector<int> sup = {0};
    for(int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        --p;
        g[p].push_back(i);
        if(p == 0) {
            sup.emplace_back(i);
        }
    }
    for(int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    for(int i: sup) {
        calc(i);
    }
    for(int i = 0; i < q; ++i) {
        int x;
        cin >> x;
        cout << ans[x - 1] << ' ';
    }
}

signed main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#else
    freopen("C:\\Users\\User\\aboab\\input.txt", "r", stdin);
#endif
    solve();
}