#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define all(x) (x).begin(), (x).end()

const int INF = 1e6;

vector<int> h;
vector<vector<int>> g;
vector<int> sz;
vector<int> color;

void dfs(int v, int p){
    if (p == -1) h[v] = 0;
    else h[v] = h[p] + 1;
    sz[v] = 1;
    for (int to: g[v]){
        if (to == p) continue;
        dfs(to, v);
        sz[v] += sz[to];
    }
}

void paint(int v, int p, int c){
    color[v] = c;
    for (int to: g[v]){
        if (to == p) continue;
        paint(to, v, c);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n, q;
    cin >> n >> q;
    vector<int> p(n, -1), s(n);
    g.resize(n);
    h.resize(n);
    sz.resize(n);
    color.resize(n, 0);
    for (int i = 1; i < n; i++){
        cin >> p[i];
        p[i]--;
        g[p[i]].push_back(i);
    }
    for (int i = 0; i < n; i++){
        cin >> s[i];
    }
    dfs(0, -1);
    int cur = 0;
    vector<array<int, 3>> sorted;
    for (int i = 1; i < n; i++){
        if (p[i] == 0){
            //cout << i << '\n';
            cur++;
            paint(i, 0, cur);
            sorted.push_back({-s[i], cur, i});
        }
    }
    /*for (int i = 0; i < n; i++){
        cout << color[i] << ' ';
    }*/
    sort(all(sorted));
    vector<vector<pair<int, int>>> query(cur + 1);
    for (int i = 0; i < q; i++){
        int v;
        cin >> v;
        v--;
        //cerr << color[v] << ' ';
        query[color[v]].push_back({v, i});
    }
    int mx = 0;
    int sum = 0;
    vector<int> ans(q);
     //first - s[i], second - color
    for (auto [a, b, c]: sorted){
        for (auto [v, i]: query[color[c]]){
            ans[i] = sum + h[v] - mx;
        }
        mx = max(mx, sz[c]);
        sum += sz[c];
    }
    for (int i = 0; i < q; i++){
        cout << ans[i] << ' ';
    }
}


