#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define int long long

const int MAX = 3e5 + 7;

vector<int> g[MAX];
int n, q;
int a[MAX];
int res[MAX];
int mn[MAX];

vector<int> st;

void dfs(int v) {
    if (v != 1) {
        st.push_back(v);
    }
    for (auto to : g[v]) {
        mn[to] = min(mn[v], a[to]);
        dfs(to);
    }
}

void solve() {
    cin >> n >> q;
    for (int i = 1; i <= n; i++) {
        res[i] = n + 1;
    }
    for (int i = 2; i <= n; i++) {
        int p;
        cin >> p;
        g[p].push_back(i);
    }
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    mn[1] = 1e18;
    for (int i = 2; i <= n; i++) {
        int was = a[i];
        a[i] = 0;
        st.clear();
        dfs(1);
        sort(st.begin(), st.end(), [&](auto p1, auto p2) {
            return (mn[p1] == mn[p2] ? a[p1] > a[p2] : mn[p1] > mn[p2]);
        });
        for (int j = 0; j < n - 1; j++) {
            if (mn[st[j]] > 0) {
                res[st[j]] = min(res[st[j]], j + 1);
            }
        }
        a[i] = was;
    }
    res[1] = 0;
    while (q--) {
        int v;
        cin >> v;
        cout << res[v] << ' ';
    }
}

int32_t main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tt = 1;
//     cin >> tt;
    while (tt--) {
        solve();
    }
}