#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define all(a) a.begin(), a.end()
vector<vector<int>> g;
vector<int> p, s;
set<pair<int, int>> cur;
vector<int> ans;
int cnt = 0;
void dfs(int u) {
    ans[u] = min(ans[u], cnt);
    for (auto to: g[u]) {
        cur.insert({s[to], to});
    }
    if (cur.empty()) {
        return;
    }
    int v = (*--cur.end()).second;
    cur.erase(--cur.end());
    cnt++;
    dfs(v);
}
void solve() {
    int n, q;
    cin >> n >> q;
    ans.assign(n, n);
    p.resize(n), s.resize(n), g.resize(n);
    for (int i = 1; i < n; ++ i) {
        cin >> p[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    for (int i = 1; i < n; ++i) {
        p[i]--;
        g[p[i]].push_back(i);
    }
    for (int i = 0; i < n; ++i) {
        int x = s[i];
        s[i] = 0;
        cnt = 0;
        dfs(0);
        s[i] = x;
    }
    while (q--) {
        int v;
        cin >> v;
        cout << ans[v - 1] << ' ';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
