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

#define f first
#define s second
#define pb push_back
#define pf push_front
#define in insert
#define nl '\n'
#define orderedSet tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update>

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC poison

typedef long double ld;
typedef int64_t int64;
typedef uint64_t uint64;
typedef uint32_t uint;

using namespace std;
using namespace __gnu_pbds;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());

//#define int int64

const int N = 3e5 + 9, sqr = 548;

multiset <int> st;
vector <int> v[N], order;
int n, q, p[N], s[N], numQ[N], ans[N], sum[N], pr[N];

main() {
    cin.tie(0); ios::sync_with_stdio(0); cout.tie(0);
    int n, q;
    cin >> n >> q;
    for (int i = 1; i < n; ++i) {
        cin >> p[i];
             --p[i];
        v[p[i]].pb(i);
    }
    for (int i = 0; i < n; ++i)
        cin >> s[i];
    set <pair <int, int>> stt = {{s[0], 0}};
    while (stt.size()) {
        auto p = *(--stt.end());
        stt.erase(--stt.end());
        order.pb(p.s);
        for (int u : v[p.s])
            stt.in({s[u], u});
    }
    fill(numQ, numQ + n, -1);
    for (int i = 0; i < q; ++i) {
        int x;
        cin >> x;
             --x;
        numQ[x] = i;
    }
    for (int uu : v[0]) {
        int u = uu;
        while (1) {
            pr[u] = uu;
            if (v[u].size() == 0)
                break;
            assert(v[u].size() == 1);
            u = v[u][0];
        }
        st.in(0);
    }
    for (int i = 0; i < n; ++i) {
        int u = order[i];
        if (u > 0) {
            st.erase(st.find(sum[pr[u]]));
            ++sum[pr[u]];
            st.in(sum[pr[u]]);
        }
        if (numQ[u] > -1) {
            if (i == 0) {
                ans[numQ[u]] = 0;
                continue;
            }
            auto it = --st.end();
            if (sum[pr[u]] != *(--st.end()))
                ans[numQ[u]] = i - *(--st.end());
            else
                ans[numQ[u]] = i - (st.size() >= 2 ? *(----st.end()) : 0);
        }
    }
    for (int i = 0; i < q; ++i)
        cout << ans[i] << " ";
}
