#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <math.h>
#include <string>
#include <vector>
#include <chrono>
#include <random>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#include <set>
#include <fstream>
#define endl '\n'

using namespace std;
using i64 = long long;
using ld = long double;

const i64 INF = 1e9 + 5;

mt19937 rnd(29);

const i64 S = 1005, K = 3e5 + 10;
vector <i64> p[K], pRev[K], gr[K];
i64 val[K];
i64 ans[S][S];

void simulate(i64 sq, i64 ind) {
	i64 t = 0;
	ans[sq][ind] = t++;
	while (p[sq].size()) {
		i64 newSq = 0, vals = -1;
		for (auto x : p[sq]) {
			if (val[x] > vals) {
				vals = val[x];
				newSq = x;
			}
		}
		for (auto x : p[sq]) {
			if (x != newSq) {
				p[newSq].push_back(x);
			}
		}
		p[sq].clear();
		ans[newSq][ind] = t++;
		sq = newSq;
	}
	return;
}

i64 check[K];
i64 tin[K], tout[K], tim = 0;

void dfs(i64 v, i64 pr) {
	tin[v] = ++tim;
	for (auto x : p[v]) {
		dfs(x, v);
	}
	tout[v] = tim;
}

vector <i64> poss;

i64 simulateBig(i64 sq, i64 psk) {
	i64 t = 0;
	t++;
	set <pair<i64, i64>> d;

	for (auto x : p[sq]) {
		d.insert({ val[x], x });
	}
	while (d.size()) {
		pair <i64, i64> k = (*(--d.end()));
		if (k.second == psk) return t;
		check[tin[k.second]] += 1;
		d.erase(k);
		for (auto x : p[k.second]) {
			d.insert({ val[x], x });
		}
		poss.push_back(k.second);
		++t;
	}
	return -1;
}

vector <i64> need;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	i64 n, q; cin >> n >> q;

	if (n <= 1000 && q <= 1000) {
		for (i64 x = 2; x <= n; ++x) {
			i64 pr; cin >> pr;
			p[pr].push_back(x);
		}

		for (i64 x = 1; x <= n; ++x) {
			cin >> val[x];
			pRev[x] = p[x];
		}

		for (i64 x = 1; x <= n; ++x) {
			i64 pre = val[x];
			val[x] = 0;
			simulate(1, x);
			for (i64 y = 1; y <= n; ++y) {
				p[y] = pRev[y];
			}
			val[x] = pre;
		}

		for (i64 x = 1; x <= q; ++x) {
			i64 answer = INF;
			i64 k; cin >> k;
			for (i64 y = 1; y <= n; ++y) {
				answer = min(answer, ans[k][y]);
			}
			cout << answer << " ";
		}
	}
	else {
		for (i64 x = 2; x <= n; ++x) {
			i64 pr; cin >> pr;
			p[pr].push_back(x);
		}

		for (i64 x = 1; x <= n; ++x) {
			cin >> val[x];
		}

		dfs(1, 1);

		for (i64 x = 1; x <= q; ++x) {
			i64 k; cin >> k;
			for (i64 y = 1; y <= n; ++y) {
				check[y] = 0;
			}
			i64 ans = simulateBig(1, k), itog = INF;
			itog = ans;
			for (i64 y = 1; y <= n; ++y) {
				check[y] += check[y - 1];
			}
			for (auto y : poss) {
				if (!(tin[y] <= tin[k] && tout[k] <= tout[y])) {
					itog = min(itog, ans - (check[tout[y]] - check[tin[y] - 1]));
				}
			}
			poss.clear();
			if (k == 1) cout << 0 << " ";
			else cout << itog << " ";
		}
	}
}