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

//#define int long long

using namespace std;

int inf = 150;
set<int> p[300000];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, q;
	cin >> n >> q;
	
	vector<vector<int>>v(n);
	for (int i = 1; i < n; ++i) {
		int x;
		cin >> x;
		x--;
		p[i] = p[x];
		p[i].insert(i);
		v[x].push_back(i);
	}
	vector<int>s(n);
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
	}
	vector<int>cnt(n);
	vector<int>ans(n);
	set<pair<int, int>>lol;
	set<pair<int, int>>huj;
	huj.insert({ -s[0],0 });
	for (int i = 0; i < n; ++i) {
		int u = huj.begin()->second;
		huj.erase(huj.begin());
		for (int x : v[u]) {
			huj.insert({ -s[x],x });
		}
		int jkl = i;
		for (pair<int, int>jopa : lol) {
			if (p[u].find(jopa.second) == p[u].end()) {
				jkl = min(jkl, i - jopa.first);
			}
		}
		ans[u] = jkl;
		for (int x : p[u]) {
			lol.erase({ cnt[x],x });
			cnt[x]++;
			lol.insert({ cnt[x],x });
		}
		while (lol.size() > inf) {
			lol.erase(lol.begin());
		}
	}
	for (; q > 0; --q) {
		int x;
		cin >> x;
		x--;
		cout << ans[x] << ' ';
	}
	return 0;
}