// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

mt19937 rnd(69); // chrono::steady_clock::now().time_since_epoch().count()
#define all(x) x.begin(), x.end()
// #define int long long
#define ull unsigned long long
#define ld long double
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2")

const long long INF = 1e15 + 69;

vector<vector<int>> graph;
vector<int> p;
vector<int> s;
vector<int> tin;
vector<int> tout;
vector<int> ans_source;
vector<int> ans_for_q;
int cur_t = 0;
int ans;

void dfs_precalc(int v, int p) {
    tin[v] = cur_t++;
    for (auto u : graph[v]) {
        if (u != p) {
            dfs_precalc(u, v);
        }
    }
    tout[v] = cur_t++;
}

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

bool cmp(int v, int u) {
    return s[v] > s[u];
}

int dfs_calc_subtree(int v, int min_q) {
    int cur_ans = 1;
    for (auto u : graph[v]) {
        if (u != p[v] && s[u] > min_q) {
            cur_ans += dfs_calc_subtree(u, min_q);
        }
    }
    ans = max(ans, cur_ans);
    return cur_ans;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    int n, q, v;
    cin >> n >> q;
    graph.resize(n);
    p.resize(n, -1);
    tin.resize(n);
    tout.resize(n);
    s.resize(n);
    ans_for_q.resize(n);
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        graph[p[i]].push_back(i);
    }
    set<pair<int, int>> first_dfs;
    first_dfs.insert({s[0], 0});
    cur_t = 0;
    ans_source.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    cur_t = 0;
    dfs_precalc(0, 0);
    cur_t = 0;
    set<pair<int, int>> cur_max = {};
    vector<int> cur_sub_active(n, 0);
    while (first_dfs.size()) {
        v = (*(--first_dfs.end())).second;
        first_dfs.erase(--first_dfs.end());
        int u = v;
        cur_max.insert({0, v});
        pair<int, int> cur_p;
        while (u > -1) {
            cur_p = {cur_sub_active[u], u};
            if ((*(cur_max.begin())) <= cur_p) {
                cur_max.erase(cur_p);
            }
            cur_sub_active[u]++;
            cur_max.insert({cur_sub_active[u], u});
            u = p[u];
            if (cur_max.size() > 105) {
                cur_max.erase(cur_max.begin());
            }
        }
        for (auto u : graph[v]) {
            first_dfs.insert({s[u], u});
        }
        auto cur_it = --cur_max.end();
        ans_source[v] = cur_t++;
        while (true) {
            if (!is_ancestor((*cur_it).second, v)) {
                ans_for_q[v] = (*cur_it).first;
                break;
            }
            if (cur_it == cur_max.begin()) {
                break;
            }
            cur_it--;
        }
    }
    for (int i = 0; i < q; i++) {
        cin >> v;
        v--;
        cout << ans_source[v] - ans_for_q[v] << " ";
    }
    return 0;
}
