#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace std;
using namespace __gnu_pbds;

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

mt19937_64 rnd(1488);

vector<vector<int>> G;
vector<int> P, cnt;
vector<int> ch1, ch2;
int a;

void update(int v) {
    int v2 = 0;
    int ans = 0;
    int v1 = P[v];
    if (ch1[v2] == cnt[v1]) {
        ++ch1[v2];
    } else if (ch2[v2] < cnt[v1] + 1) {
        ch2[v2] = cnt[v1] + 1;
    }
    cnt[v1] += 1;
}

int ga(int v) {
    int v2 = 0;
    int ans = 0;
    int v1 = P[v];
    auto cr = ch1[v2];
    int cr1 = 0;
    if (cnt[v1] == cr) {
        cr = ch2[v2];
    }
    ans = max(ans, cr);
    return ans;
}

void dfs(int v) {
    if (P[v] != -1) {
        P[v] = P[P[v]];
    }
    if (P[v] <= 0) {
        P[v] = v;
    }
    for (auto i : G[v]) {
        dfs(i);
    }
}

signed main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int q;
    cin >> a >> q;
    P.resize(a, -1);
    G.resize(a);
    ch1.resize(a, 0);
    ch2.resize(a, 0);
    cnt.resize(a);
    for (int i = 1; i < a; ++i) {
        int b;
        cin >> b;
        --b;
        G[b].push_back(i);
        P[i] = b;
    }
    dfs(0);
    set<pair<int, int>> C;
    vector<int> C1(a);
    for (int i = 0; i < a; ++i) {
        cin >> C1[i];
    }
    vector<int> ans(q), Q(a, -1);
    for (int i = 0; i < q; ++i) {
        int q1;
        cin >> q1;
        --q1;
        Q[q1] = i;
    }
    C.insert({0, 0});
    for (int i = 0; i < a; ++i) {
        int op = C.begin()->second;
        //cout << op << endl;
        //cout << op << ' ' << ga(op) << endl;
        if (Q[op] >= 0) {
            ans[Q[op]] = i - ga(op);
        }
        update(op);
        C.erase(C.begin());
        for (auto i : G[op]) {
            C.insert({-C1[i], i});
        }
    }
    for (auto i : ans) {
        cout << i << ' ';
    }
}

