#include <bits/stdc++.h>

using namespace std;
#define int long long
#define F first
#define S second
vector<vector<int>> g;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    g.resize(n);
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        --p;
        g[p].push_back(i);
    }
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<int> ans(n);
    set<pair<int, pair<int, int>>, greater<>> s;
    for (auto u: g[0]) {
        s.insert({a[u], {u, u}});
    }

    map<int, int> mp;
    set<pair<int, int>> mxmp;
    int it = 0;
    while (!s.empty()) {
        ++it;
        auto [x, v] = *s.begin();
        s.erase(s.begin());
        ans[v.F] = it;
        for (auto i: mxmp) {
            if (i.S != v.S) {
                ans[v.F] -= i.F;
                break;
            }
        }
        mxmp.erase({mp[v.S], v.S});
        mp[v.S]++;
        mxmp.insert({mp[v.S], v.S});
        for (auto u: g[v.F]) {
            s.insert({a[u], {u, v.S}});
        }
    }

    for (int i = 0; i < q; ++i) {
        int v;
        cin >> v;
        --v;
        if (v == 0) {
            cout << 0 << "\n";
        } else {
            cout << ans[v] << "\n";
        }
    }
    return 0;
}
