#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;

vector <int> v[N], order;
int n, q, p[N], s[N], numQ[N], ans[N], sum[N], mp[N], mp2[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;
    }
    mp[0] = N;
    mp2[0] = N;
    for (int i = 0; i < n; ++i) {
        int u = order[i],
            uu = u;
        while (1) {
            --mp[sum[uu]];
            --mp2[sum[uu] / sqr];
            ++sum[uu];
            ++mp[sum[uu]];
            ++mp2[sum[uu] / sqr];
            if (uu == 0)
                break;
            uu = p[uu];
        }
        if (numQ[u] > -1) {
            uu = u;
            while (1) {
                --mp[sum[uu]];
                --mp2[sum[uu] / sqr];
                if (uu == 0)
                    break;
                uu = p[uu];
            }
            int mx = n;
            while (mp2[mx / sqr] == 0)
                mx = mx / sqr * sqr - 1;
            while (mp[mx] == 0)
                --mx;
            ans[numQ[u]] = i - mx;
            uu = u;
            while (1) {
                ++mp[sum[uu]];
                ++mp2[sum[uu] / sqr];
                if (uu == 0)
                    break;
                uu = p[uu];
            }
        }
    }
    for (int i = 0; i < q; ++i)
        cout << ans[i] << " ";
}
