//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <numeric>
#include <algorithm>
#include <random>
using ll = long long;
//#define int ll
#define all(a) a.begin(), a.end()

using namespace std;
//using namespace __gnu_pbds;

//using odered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rnd(0);

vector<int> par, s;
vector<set<int>> g;

void solve() {
	int n, q;
	cin >> n >> q;
	par.resize(n);
	g.resize(n);
	s.resize(n);
	for (int i = 1; i < n; i++) {
		cin >> par[i];
		par[i]--;
		g[par[i]].insert(i);
	}
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	vector<int> ans(n);
	vector<set<pair<int, int>>> gs(n);
	for (int i = 0; i < n; i++) {
		for (auto to : g[i]) {
			gs[i].insert({ s[to], to });
		}
	}
	vector<int> cnt(n);
	int tm = 0;
	while (gs[0].size()) {
		auto to = prev(gs[0].end())->second;
		gs[0].erase(prev(gs[0].end()));
		for (auto w : gs[to]) {
			gs[0].insert(w);
		}
		auto cnt1 = cnt;
		int to1 = to;
		while (to1 != 0) {
			cnt[to1]++;
			cnt1[to1] = 0;
			to1 = par[to1];
		}
		ans[to] = 1e9;
		tm++;
		for (auto i : cnt1) {
			ans[to] = min(ans[to], tm - i);
		}
	}
	while (q--) {
		int i;
		cin >> i;
		i--;
		cout << ans[i] << ' ';
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef LOCAL
	auto f1 = freopen("input.txt", "r", stdin);
	auto f2 = freopen("output.txt", "w", stdout);
#endif

	solve();
}