#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
// #pragma GCC optimize("03")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("avx,avx2,bmi2,fma")


vector<vector<int>> g;
vector<int> p, s, dir, ans;

void dfs(int v) {
    // cout << "F " << v << endl;
    int Max = 0, ind = -1;
    for (auto& it : g[v]) {
        if (Max < s[it]) {
            Max = s[it];
            ind = it;
        }
    }
    if (ind == -1) {
        return;
    }
    dir.push_back(ind);
    for (auto& it : g[v]) {
        if (it == ind) {
            continue;
        }
        g[ind].push_back(it);
    }
    dfs(ind);
}

bool check(int start) {
    int now = start;
    while (now != p[now]) {
        now = p[now];
        if (ans[now] < ans[start]) {
            return true;
        }
    }
    return false;
}

signed main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n, q;
    cin >> n >> q;
    g.resize(n);
    p.resize(n);
    s.resize(n);
    for (int i = 1; i < n; ++i) {
        cin >> p[i];
        p[i]--;
        g[p[i]].push_back(i);
    }
    for (auto& it : s) {
        cin >> it;
    }
    dir.push_back(0);
    dfs(0);

    ans.resize(n);
    for (int i = 0; i < n; ++i) {
        ans[dir[i]] = i;
    }

    while (q--) {
        int v;
        cin >> v;
        v--;
        int now = ans[v];
        if (check(v)) {
            now--;
        }
        cout << now << ' ';
    }
}

/*
5 4
1 2 2 1
3 5 1 2 4
5 3 1 4


1 3 0 2
*/