#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;

vector<vector<int>> g;

int main(){
	int n, q;
	cin >> n >> q;
	g.resize(n);
	vector<int> S(n);
	for (int i = 1; i < n; i++) {
		int v;
		cin >> v;
		v--;
		g[v].push_back(i);
	}
	for (int i = 0; i < n; i++) {
		cin >> S[i];
		S[i] = -S[i];
	}
	vector<vector<int>> d(g[0].size());
	int cnt = 0;
	vector<int> clrs(n);
	for (auto to : g[0]) {
		int k = to;
		clrs[k] = cnt;
		while (g[k].size() != 0) {
			d[cnt].push_back(k);
			clrs[k] = cnt;
			k = g[k][0];
		}
		d[cnt].push_back(k);
		clrs[k] = cnt;
		cnt++;
	}
	set <pair<int, pair<int,int>>> s;
	for (int i = 0; i < d.size(); i++) {
		s.insert({ S[d[i][0]], {i, 0} });
	}
	vector<int> p(d.size());
	pair<int, int> max1 = { 0,0 };
	pair<int, int> max2 = { 0,0 };
	vector<pair<pair<int, int>, pair<int, int>>> mxs;
	int sum1 = 0;
	vector<int> dp(n);
	while (!s.empty()) {
		pair<int, pair<int, int>> x = *s.begin();
		p[x.second.first]++;
		if (max1.first < p[x.second.first]) {
			max2 = max1;
			max1 = { p[x.second.first], x.second.first };
		}
		else if (max2.first < p[x.second.first]) {
			max2 = { p[x.second.first], x.second.first };
		}
		mxs.push_back({ max1, max2 });
		sum1++;
		dp[d[x.second.first][x.second.second]] = sum1;
		if (x.second.second == d[x.second.first].size() - 1) {
			continue;
		}
		s.insert({ S[d[x.second.first][x.second.second + 1]], {x.second.first, x.second.second + 1} });
	}
	while (q--) {
		int c;
		cin >> c;
		c--;
		if (c == 0) {
			cout << 0 << ' ';
			continue;
		}
		int o = dp[c];
		if (o == 1) {
			cout << o << ' ';
			continue;
		}
		if (clrs[c] != mxs[dp[c]].first.second) {
			cout << dp[c] - mxs[dp[c]].first.second << ' ';
		}
		else {
			cout << dp[c] - mxs[dp[c]].second.first << ' ';
		}
	}
}