#include <bits/stdc++.h>

using namespace std;

vector<vector<int>> g;
vector<int> s;
vector<int> pau;

void bfs() {
    set<pair<int, int>> q;
    q.insert({s[0], 0});
    int ind = 0;
    while (!q.empty()) {
        auto cur = q.rbegin();
        int v = cur->second;
        pau[v] = ind++;
        q.erase(*cur);
        for (auto to : g[v]) {
            q.insert({s[to], to});
        }
    }
}

void solve() {
    int n, q; cin >> n>> q;
    vector<int> p(n);
    s.resize(n);
    g.resize(n);
    pau.resize(n);;
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        g[p[i]].push_back(i);
    }
    for (auto& i : s) cin >> i;
    bfs();
    while (q--) {
        int u; cin >> u; u--;
        cout << pau[u] << '\n';
    }
    cout << '\n';
}

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    solve();
}
