#pragma GCC optimize("Ofast,fast-math,unroll-loops,no-stack-protector,inline")
#include <bits/stdc++.h>

using namespace std;

#define int long long

int n;
vector<vector<int>> gr;
vector<int> el_ob, par, ind, ind_do;
vector<int> tree, ch;

int dfs(int v) {
    int cur = 0, sm = 1;
    for (int j = 0; j < gr[v].size(); j++) {
        int u = gr[v][j];
        int cur1 = dfs(u);
        sm += cur1;
        if (cur1 > cur) {
            swap(gr[v][j], gr[v][0]);
            cur = cur1;
        }
    }
    return sm;
}

void dfs1(int v, int ind_p = 0) {
    ind[v] = el_ob.size();
    el_ob.push_back(v);
    ind_do[v] = ind_p;
    for (int j = 0; j < gr[v].size(); j++) {
        int u = gr[v][j];
        if (j == 0) {
            dfs1(u, ind_p);
        } else {
            dfs1(u, el_ob.size());
        }
    }
}

void push(int v, int l, int r) {
    if (r - l == 1 || ch[v] == 0) return;
    tree[v * 2 + 1] += ch[v];
    tree[v * 2 + 2] += ch[v];
    ch[v * 2 + 1] += ch[v];
    ch[v * 2 + 2] += ch[v];
    ch[v] = 0;
}

void update(int v, int l, int r, int ql, int qr) {
    if (r <= ql || qr <= l) {
        return;
    } else if (ql <= l && r <= qr) {
        tree[v]++;
        ch[v]++;
    } else {
        int m = (r + l) / 2;
        push(v, l, r);
        update(v * 2 + 1, l, m, ql, qr);
        update(v * 2 + 2, m, r, ql, qr);
        tree[v] = max(tree[v * 2 + 1], tree[v * 2 + 2]);
    }
}

int get(int v, int l, int r, int ql, int qr) {
    if (r <= ql || qr <= l) {
        return 0;
    } else if (ql <= l && r <= qr) {
        return tree[v];
    } else {
        push(v, l, r);
        int m = (r + l) / 2;
        return max(get(v * 2 + 1, l, m, ql, qr), get(v * 2 + 2, m, r, ql, qr));
    }
}

void upd(int v) {
    while (v != -1) {
        update(0, 0, n, ind_do[v], ind[v] + 1);
        v = par[el_ob[ind_do[v]]];
    }
}


int day(int v) {
    vector<pair<int, int>> cur;
    cur.push_back({n, n});
    while (v != -1) {
        cur.push_back({ind_do[v], ind[v] + 1});
        v = par[el_ob[ind_do[v]]];
    }
    cur.push_back({0, 0});
    reverse(cur.begin(), cur.end());
    int mx = 0;
    for (int i = 1; i < cur.size(); i++) {
        mx = max(mx, get(0, 0, n, cur[i - 1].second, cur[i].first));
    }
    return mx;
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    freopen("input.txt", "r", stdin);
    int q;
    cin >> n >> q;
    gr.resize(n);
    par.resize(n);
    ind.resize(n);
    ind_do.resize(n);
    tree.resize(4 * n);
    ch.resize(4 * n);
    par[0] = -1;
    for (int i = 1; i < n; i++) {
        int a;
        cin >> a;
        a--;
        par[i] = a;
        gr[a].push_back(i);
    }
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    dfs(0);
    dfs1(0);
    vector<int> p;
    set<pair<int, int>> st;
    st.insert({0, 0});
    while (!st.empty()) {
        auto [sm, v] = *st.begin();
        p.push_back(v);
        st.erase(st.begin());
        for (int u : gr[v]) {
            st.insert({-arr[u], u});
        }
    }
    vector<int> ans(n);
    for (int i = 0; i < n; i++) {
        ans[p[i]] = i - day(p[i]);
        upd(p[i]);
    }
    for (int t = 0; t < q; t++) {
        int a;
        cin >> a;
        a--;
        cout << ans[a] << ' ';
    }
    cout << endl;
}