//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <iomanip>

using namespace std;

long long n, q;
vector<vector<long long>> g;
vector<long long> pr, s, ans1, zap, zap2, dp;
multiset<pair<long long, long long>> stm, pod;

long long parent(long long v) {
	if (pr[v] < 1 || g[pr[v]].size() > 1)
		return v;
	else
		return pr[v] = parent(pr[v]);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> n >> q;

	g.resize(n);
	pr.resize(n, -1);
	s.resize(n);
	zap.resize(n, 0);
	ans1.resize(n, 0);
	zap2.resize(q, 0);
	dp.resize(n, 0);

	for (long long i = 0; i < n; ++i) {
		if (pr[i] < 1 || g[i].size() > 1)
			pod.insert({ 0, i });
	}

	for (long long i = 1; i < n; ++i) {
		cin >> pr[i];
		--pr[i];
		g[pr[i]].push_back(i);
	}

	for (long long i = 1; i < n; ++i)
		if (pr[i] != 0 && g[pr[i]].size() == 1)
			pr[i] = parent(i);

	for (long long i = 0; i < n; ++i)
		cin >> s[i];

	for (long long i = 0; i < q; ++i) {
		cin >> zap2[i];
		--zap2[i];
		zap[zap2[i]] = 1;
	}

	long long sh = 0;
	stm.insert({ s[0], 0 });

	while (!stm.empty()) {
		long long ind = (*(--stm.end())).second;
		stm.erase((--stm.end()));
		if (zap[ind] == 1) {
			vector<long long> prr;
			long long a = ind;
			while (pr[a] != -1) {
				a = pr[a];
				prr.push_back(a);
			}

			long long x3 = 0, nom = (long long)prr.size() - 1;
			for (auto it2 = pod.end(); it2 != pod.begin(); --it2) {
				auto it = --it2;
				++it2;
				if (nom < 0 || prr[nom] != (*it).second) {
					x3 = (*it).first;
					break;
				}
				--nom;
			}
			ans1[ind] = sh - x3;
		}
		if (pr[ind] < 1 || g[ind].size() > 1) {
			pod.erase({ dp[ind], ind });
			++dp[ind];
			pod.insert({ dp[ind], ind });
		}
		long long a = ind;
		while (pr[a] != -1) {
			a = pr[a];
			if (pr[a] < 1 || g[a].size() > 1) {
				pod.erase({ dp[a], a });
				++dp[a];
				pod.insert({ dp[a], a });
			}
		}

		for (long long i = 0; i < g[ind].size(); ++i) {
			stm.insert({ s[g[ind][i]], g[ind][i] });
		}

		++sh;
	}

	for (long long i = 0; i < q; ++i)
		cout << ans1[zap2[i]] << ' ';

	return 0;
};
