#include <iostream>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <bitset>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <random>

using namespace std;

random_device rd;
mt19937 rnd(rd());

// #define int long long
using pii = pair<int, int>;

const int max_n = 3e5 + 5;

vector<int> g[max_n];

vector<int> tin(max_n), tout(max_n);
int tr = 0;

void dfs(int v) {
    tin[v] = tr++;
    for (int u : g[v]) {
        dfs(u);
    }
    tout[v] = tr++;
}

bool is_v_anc_of_u(int v, int u) {
    return tin[v] <= tin[u] && tout[u] <= tout[v];
}

void solve() {
    int n, q; cin >> n >> q;
    vector<int> p(n);
    p[0] = -1;
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        g[p[i]].push_back(i);
    }
    dfs(0);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    set<pii> s;
    s.insert({-a[0], 0});
    vector<int> ord;
    while (!s.empty()) {
        auto [val, v] = *s.begin();
        s.erase({val, v});
        ord.push_back(v);
        for (int u : g[v]) {
            s.insert({-a[u], u});
        }
    }
    vector<int> cnt(n, 0);
    vector<int> v_res(n, 0);
    for (int i = 0; i < n; i++) {
        int v = ord[i];
        int temp = 0;
        for (int u = 0; u < n; u++) {
            if (!is_v_anc_of_u(u, v)) {
                temp = max(temp, cnt[u]);
            }
        }
        v_res[v] = i - temp;
        int u = v;
        while (u != -1) {
            cnt[u]++;
            u = p[u];
        }
    }
    while (q--) {
        int v; cin >> v;
        v--;
        cout << v_res[v] << " ";
    }
}

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

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}
