#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, Q;
    cin >> n >> Q;
    vector<int> p(n);
    p[0] = 0;
    vector<vector<int>> gr(n);
    my_map[{0, 0}] = true;
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        gr[p[i]].push_back(i);
    }
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    set<pair<int, int>> ans;
    ans.insert({-s[0], 0});
    vector<int> vec;
    while (!ans.empty()) {
        pair<int, int> c = *ans.begin();
        ans.erase(c);
        vec.push_back(c.second);
        for (auto x : gr[c.second]) {
            ans.insert({-s[x], x});
        }
    }
    set<pair<int, int>> st;
    vector<pair<int, int>> answ(n);
    vector<int> q(n);
    vector<int> answer(n);
    for (int i = 0; i < n; i++) {
        int v = vec[i];
        q[v]++;
        int mx = 0;
        while (true) {
            if (v == p[v]) {
                break;
            } else {
                q[p[v]]++;
                if (q[v] - 1 == answ[p[v]].first) {
                    answ[p[v]].first++;
                    mx = max(mx, answ[p[v]].second);
                } else if (q[v] - 1 == answ[p[v]].second) {
                    mx = max(mx, answ[p[v]].first);
                    answ[p[v]].second++;
                } else {
                    mx = max(mx, answ[p[v]].first);
                    answ[p[v]].second = max(answ[p[v]].second, q[v]);
                }
                v = p[v];
            }
        }
        answer[vec[i]] = i - mx;
    }
    for (int i = 0; i < Q; i++) {
        int v;
        cin >> v;
        v--;
        cout << answer[v] << " ";
    }
}
