//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
//#pragma GCC target("avx, avx2, tune=native")
#define int long long
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define pi pair<int, int>


using namespace std;

void solve() {
    int n, q;
    cin >> n >> q;
    vector<vector<int>> g(n);
    vector<int> s(n), col(n);
    int c = 0;
    for (int i = 0; i < n; ++i) {
        int p;
        cin >> p;
        --p;
        if (p == 0) {
            col[i] = c++;
        } else {
            col[i] = col[p];
        }
        g[p].push_back(i);
    }
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        s[i] = -s[i];
    }
    set<pi> st;
    vector<int> a;
    st.insert({0, 0});
    while (!st.empty()) {
        int u = st.begin()->s;
        a.push_back(u);
        st.erase(st.begin());
        for (auto& v : g[u]) {
            st.insert({s[v], v});
        }
    }
    vector<int> res(n);
    set<pi> cnt;
    vector<int> ct(c);
    for (int i = 0; i < c; ++i) {
        cnt.insert({0, i});
    }
    for (int i = 1; i < n; ++i) {
        int cr = i;
        auto it = cnt.begin();
        if (it->s == col[a[i]]) {
            ++it;
        }
        if (it != cnt.end()) {
            cr -= it->f;
        }
        res[i] = cr;
        cnt.erase({-ct[col[a[i]]], col[a[i]]});
        ++ct[col[a[i]]];
        cnt.insert({-ct[col[a[i]]], col[a[i]]});
    }
    for (int i = 0; i < q; ++i) {
        int u;
        cin >> u;
        --u;
        cout << res[u] << " "[i == q - 1];
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}
