#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;
	str(int n) {
		n2 = 1;
		while (n2 < n) n2 *= 2;
		vec.assign(2 * n2, 0);
	}
	void inc(int i, int x, int ql, int qr, int v) {
		if (ql + 1 == qr) {
			vec[v] += x;
			return;
		}
		int m = (ql + qr) / 2;
		if (i < m) {
			inc(i, x, ql, m, 2 * v + 1);
		}
		else {
			inc(i, x, m, qr, 2 * v + 2);
		}
		vec[v] = max(vec[2 * v + 1], vec[2 * v + 2]);
	}
};

vi tin;
vi tout;
vvi graph;
int tim = 0;
void dfs(int u) {
	tin[u] = tim;
	for (int v : graph[u]) {
		tim++;
		dfs(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);
	vi par(n);
	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);
	set<pi> x;
	vi val(n);
	val[0] = 1;
	for (int i = 1; i < n; i++) {
		int u = tvec[i];
		while (1) {
			x.erase({ val[u], u });
			val[u] -= 1e9;
			x.insert({ val[u], u });
			if (!u) break;
			u = par[u];
		}
		ans[tvec[i]] = min(i, i - x.rbegin()->ff);
		u = tvec[i];
		while (1) {
			x.erase({ val[u], u });
			val[u] += 1e9;
			x.insert({ val[u], u });
			if (!u) break;
			u = par[u];
		}
		u = tvec[i];
		while (1) {
			x.erase({ val[u], u });
			val[u] += 1;
			x.insert({ val[u], u });
			if (!u) break;
			u = par[u];
		}
	}

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