#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef string str;
mt19937 rnd(157);

#define all(a) a.begin(), a.end()
#define int long long

int n, q;
//vector<vector<int>> g;
vector<int> s;
vector<int> ab;
//vector<vector<int>> questions;
vector<int> pr;

vector<vector<pair<int, int>>> g;
int now = 0;
int nowmax = 0;
vector<int> wei;
vector<int> hahans;

void dfs(int v) {
//    cout << v << endl;
    wei[v] = now;
    now++;
    hahans[v] = nowmax;
    for(auto [w, u] : g[v]) {
        dfs(u);
    }
    nowmax = max(nowmax, now - wei[v]);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    cin >> n >> q;
    g.resize(n);
    pr.resize(n, 0);
    for(int i = 1; i < n; i++) {
        int p;
        cin >> p;
        p--;
        pr[i] = p;
    }
    s.resize(n);
    for(int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for(int i = 1; i < n; i++) {
        g[pr[i]].emplace_back(s[i], i);
    }
    for(int i = 0; i < n; i++) {
        sort(all(g[i]));
        reverse(all(g[i]));
    }
    wei.resize(n, 0);
    hahans.resize(n, 0);

    dfs(0);


    for(int i = 0; i < q; i++) {
        int h;
        cin >> h;
        ab.push_back(h - 1);
    }

    vector<int> ans3(n, n);
    set<pair<int, int>> que;
    que.insert({0, 0});
    vector<int> ans1(n);
//        vector<int> ans2(n, 0);
//    questions.resize(n);
//        vector<vector<int>> bros(n);
    for (int i = 0; i < n; i++) {
        auto [w, v] = *que.rbegin();
//        cout << w << ' ' << v << endl;
        ans1[v] = i;
        que.erase(*que.rbegin());
//            vector<int> hh;
        for (auto[w, u]: g[v]) {
//                hh.push_back(u);
            que.insert({s[u], u});
        }
    }
    for (int i = 0; i < n; i++) {
        ans3[i] = min(ans3[i], ans1[i]);
    }




    for(auto el : ab) {
        cout << ans3[el] - hahans[el] << ' ';
    }

}
