#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <cmath>
#include <map>
#include <iomanip>
#include <queue>
#include <unordered_map>
using namespace std;
using ll = long long;
vector<vector<ll>> gr, gr2;
vector<ll> s;
void dfs(vector<ll>& val, ll v, ll c) {
	if (c > s[v])
		return;
	val[v]++;
	for (auto& to : gr[v]) {
		dfs(val, to, c);
		val[v] += val[to];
	}
}

struct node {
	ll mx = 0, mx2 = 0;
	ll from = -1, from2 = -1;
};
vector<node> mxm;
ll maxim(ll f, ll u) {
	if (f == mxm[u].from)
		return mxm[u].mx2;
	return mxm[u].mx;
}
void smx(ll f, ll u, ll x) {
	if (x <= mxm[u].mx2) return;
	if (x > mxm[u].mx) {
		if (f != mxm[u].from)
			mxm[u].from2 = mxm[u].from, mxm[u].mx2 = mxm[u].mx;
		mxm[u].mx = x; mxm[u].from = f;
		return;
	}
	if (mxm[u].mx == mxm[u].mx2) return;
	if (f == mxm[u].mx)
		return;
	mxm[u].mx2 = x; mxm[u].from2 = f;
}
void solve() {
	ll n, q;
	cin >> n >> q;
	vector<ll> p(n, -1),h(n);
	s.resize(n); gr.resize(n); gr2.resize(n);
	for (ll i = 1; i < n; ++i) {
		cin >> p[i];
		--p[i];
		gr[p[i]].push_back(i);
		h[i] = h[p[i]] + 1;	
	}
	for (ll i = 0; i < n; ++i)
		cin >> s[i];
	priority_queue<pair<ll, ll>> pq;
	pq.push({ 0, 0 });
	vector<ll> val(n);
	vector<ll> ans(n);
	mxm.resize(n);
	for (ll i = 0; i < n; ++i) {
		ll u = pq.top().second;
		pq.pop();
		if (p[u] == 0)
			p[u] = u;
		if (p[u] > 0)
			p[u] = p[p[u]];
		for (auto& to : gr[u]) 
			pq.push({ s[to], to });
		ll mx = 0;
		if (p[u] > 0) 
			u = p[u];
		++val[u];
		if (p[u] != -1) {
			mx = max(mx, maxim(u, p[u]));
			smx(u, p[u], val[u]);
		}
		ans[u] = i - mx;
	}
	/*while (tu != -1) {
			++val[tu];
			if (p[tu] != -1) {
				mx = max(mx, maxim(tu, p[tu]));
				smx(tu, p[tu], val[tu]);
			}
			tu = p[tu];
		}*/
	for (ll i = 0; i < q; ++i) {
		ll u;
		cin >> u;
		--u;
		cout << ans[u] << " ";
	}
}

int main() {
#ifdef _DEBUG
	freopen("input2.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll t = 1;
	// cin >> t;
	while (t--)
		solve();
}