#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#define all(v) v.begin(), v.end()
#define fi first
#define se second

using namespace std;
typedef int ll;
typedef long double ld;
typedef pair<int, int> pii;

const ll SZ = 3e5 + 1;

vector<ll> g[SZ];
priority_queue<pii> pq[SZ];

void solve() {
	ll n, q, v;
	cin >> n >> q;
	vector<ll> p(n, -1);
	vector<ll> s(n);
	for (ll i = 1; i < n; i++) cin >> p[i];
	for (ll i = 0; i < n; i++) cin >> s[i];
	for (ll i = 1; i < n; i++) {
		--p[i];
		g[p[i]].push_back(i);
	}
	vector<ll> cnt(n);
	vector<ll> ans(n);
	set<pii> se;
	ans[0] = 0;
	for (ll i = 1; i < n; i++) {
		pq[p[i]].push({ s[i], i });
	}
	for (ll i = 0; i < n - 1; i++) {
		auto pi = pq[0].top();
		pq[0].pop();
		ll u = pi.se;
		ll temp = u;
		while (p[temp] != -1) {
			se.erase({ cnt[temp], temp });
			temp = p[temp];
		}
		if (!se.empty()) {
			auto it = se.end();
			it--;
			ans[u] = i + 1 - it->fi;
		}
		else {
			ans[u] = i + 1;
		}
		temp = u;
		while (p[temp] != -1) {
			cnt[temp]++;
			se.insert({ cnt[temp], temp });
			temp = p[temp];
		}
		ll in1 = 0, in2 = u;
		if (pq[in2].size() > pq[in1].size()) {
			swap(pq[in1], pq[in2]);
		}
		while (!pq[in2].empty()) {
			pi = pq[in2].top();
			pq[in2].pop();
			pq[in1].push(pi);
		}
	}
	for (ll i = 0; i < q; i++) {
		cin >> v;
		cout << ans[--v] << ' ';
	}
	cout << '\n';
}

int main() {
	ll t = 1;
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	cin >> t;
#else
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
#endif
	while (t--) solve();
}
