#include <iostream>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <assert.h>
using namespace std;

//#define int long long
#define ll long long
#define vi vector<int>
#define pi pair<int, int>
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define vpi vector<pi>
#define vvi vector<vi>

struct str {
	int n2;
	vi vec;
	vi add;
	str(int n = 0) {
		n2 = 1;
		while (n2 < n) n2 *= 2;
		vec.assign(2 * n2, 0);
		add.assign(2 * n2, 0);
	}
	void inc(int l, int r, int x, int ql, int qr, int v) {
		if (ql + 1 != qr && add[v]) {
			vec[2 * v + 1] += add[v];
			vec[2 * v + 2] += add[v];
			add[2 * v + 1] += add[v];
			add[2 * v + 2] += add[v];
			add[v] = 0;
		}
		if (l <= ql && qr <= r) {
			add[v] += x;
			vec[v] += x;
			return;
		}
		if (ql >= r) return;
		if (l >= qr) return;
		int m = (ql + qr) / 2;
		inc(l, r, x, ql, m, 2 * v + 1);
		inc(l, r, x, m, qr, 2 * v + 2);
		vec[v] = max(vec[2 * v + 1], vec[2 * v + 2]);
	}
};

vi tin;
vi tout;
vvi graph;
vi sz;
vi par;
vi upper_heavy;
int tim = 0;
void dfs(int u) {
	tin[u] = tim;
	for (int v : graph[u]) {
		tim++;
		dfs(v);
		sz[u] += sz[v];
	}
	tout[u] = tim;
}
bool cmp(int u, int v) {
	return sz[u] > sz[v];
}
void decomp(int u) {
	sort(all(graph[u]), cmp);
	for (int v : graph[u]) {
		if (v == graph[u][0]) {
			upper_heavy[v] = upper_heavy[u];
		}
		else {
			upper_heavy[v] = v;
		}
		decomp(v);
	}
}

str tr;
void inc(int u, int x) {
	while (1) {
		if (upper_heavy[u] == 0) {
			tr.inc(0, tin[u] + 1, x, 0, tr.n2, 0);
			return;
		}
		else {
			int v = upper_heavy[u];
			tr.inc(tin[v], tin[u] + 1, x, 0, tr.n2, 0);
			u = par[v];
		}
	}
}

signed main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n, q;
	cin >> n >> q;
	vi ans(n);
	vi vec(n);
	graph.assign(n, vi());
	tin.assign(n, 0);
	tout.assign(n, 0);
	sz.assign(n, 1);
	upper_heavy.assign(n, 0);
	par.assign(n, 0);
	for (int i = 0; i < n - 1; i++) {
		int a;
		cin >> a;
		a--;
		graph[a].push_back(i + 1);
		par[i + 1] = a;
	}
	for (int i = 0; i < n; i++) cin >> vec[i];
	set<pi> cand;
	cand.insert({ vec[0], 0 });
	vi tvec;
	while (cand.size()) {
		pi x = *cand.rbegin();
		cand.erase(x);
		tvec.push_back(x.ss);
		for (int y : graph[x.ss]) {
			cand.insert({ vec[y], y });
		}
	}
	dfs(0);
	decomp(0);
	tim = 0;
	dfs(0);

	tr = str(n);

	inc(0, 1);
	for (int i = 1; i < n; i++) {
		inc(tvec[i], -1e9);
		ans[tvec[i]] = min(i, i - tr.vec[0]);
		inc(tvec[i], 1e9);
		inc(tvec[i], 1);
	}

	while (q--) {
		int x;
		cin >> x;
		cout << ans[x - 1] << ' ';
	}
}
