#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

//#define int long long
#define endl "\n"
#define ff first
#define ss second
#define ordered_set tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>
#define all(x) x.begin(), x.end()

vector<vector<int>> g;
vector<int> s;

vector<int> posl;
set<pair<int, int>> st;

void dfs(int v) {
    posl.push_back(v);
    for (auto u: g[v]) {
        st.insert({s[u], u});
    }
    if (st.size() == 0) {
        return;
    }
    auto bst = *(--st.end());
    st.erase(bst);
    dfs(bst.ss);

}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n, q;
    cin >> n >> q;

    g.resize(n);
    s.resize(n);
    vector<int> p(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);

//    for (auto it: posl) {
//        cout << it << " ";
//    }
//    cout << endl;

    vector<int> pc(n, 0);

    vector<int> vls(n);
    vector<int> cnt(n + 1);
    vector<int> lst(n + 1);

    cnt[0] = n;
    lst[0] = n - 1;

    vector<int> ans(n, -1);

    for (int i = 0; i < n; i++) {
        int v = posl[i];
        vector<int> tc;
        while (v != 0) {
            tc.push_back(pc[v]);
            pc[v]++;
            v = p[v];
        }
        for (auto it: tc) {
            vls[lst[it]]++;
            lst[it]--;
            cnt[it]--;
            cnt[it + 1]++;
            if (cnt[it + 1] == 1) {
                lst[it + 1] = lst[it] + 1;
            }
        }
        sort(all(tc));
        int cmx = 0;
        for (int j = n - 1; j >= 0; j--) {
            if (tc.size() == 0 || tc.back() + 1 != vls[j]) {
                cmx = vls[j];
                break;
            }
            tc.pop_back();
        }
        ans[posl[i]] = i - cmx;
    }

    while (q--) {
        int v;
        cin >> v;
        v--;
        cout << ans[v] << " ";
    }

}
