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

#define len(v) (int)((v).size())
#define ss second
#define ff first


typedef long long ll;

using namespace std;


struct obj {
	int x;
	obj(int x) : x(x) {}
	obj() : obj(0) {}

	static obj merge(const obj& a, const obj& b) {
		obj res;
		res.x = max(a.x, b.x);
		return res;
	}
};

struct info {
	int x;
	info(int x) : x(x) {}
	info() : info(0) {}

	static void upd(obj& a, const info& b, int ln) {
		a.x += b.x;
	};
	static void upd(info& a, const info& b, int ln) {
		a.x += b.x;
	};
	bool is_empty() {
		return x == 0;
	}
};

struct ST {
	static const int sz = 1 << 20;
	obj tree[sz];
	info add[sz];

	void build(int v, int l, int r, vector<int>& a) {
		if (r - l == 1) {
			tree[v] = obj(a[l]);
			return;
		}
		int m = (l + r) / 2;
		build(v * 2, l, m, a);
		build(v * 2 + 1, m, r, a);
		tree[v] = obj::merge(tree[v * 2], tree[v * 2 + 1]);
	}
	void push(int v, int l, int r) {
		if (add[v].is_empty()) return;

		if (r - l > 1) {
			info::upd(add[v * 2], add[v], r - l);
			info::upd(add[v * 2 + 1], add[v], r - l);
		}
		info::upd(tree[v], add[v], r - l);
		add[v] = info();
	}
	void upd(int v, int l, int r, int ql, int qr, info qx) {
		push(v, l, r);
		if (l >= qr || ql >= r) return;
		if (l >= ql && r <= qr) {
			add[v].upd(add[v], qx, r - l);
			push(v, l, r);
			return;
		}
		int m = (l + r) / 2;
		upd(v * 2, l, m, ql, qr, qx);
		upd(v * 2 + 1, m, r, ql, qr, qx);
		tree[v] = obj::merge(tree[v * 2], tree[v * 2 + 1]);
	}
	obj get(int v, int l, int r, int ql, int qr) {
		push(v, l, r);
		if (l >= qr || ql >= r) return obj();
		if (l >= ql && r <= qr) return tree[v];
		int m = (l + r) / 2;
		obj r1 = get(v * 2, l, m, ql, qr);
		obj r2 = get(v * 2 + 1, m, r, ql, qr);
		return obj::merge(r1, r2);
	}
} tree;

const int N = 3e5 + 7;

vector<int> g[N];

int tim = 0;
int ti[N], to[N], h[N], st[N], sz[N], p[N];

void dfs1(int v, int hi) {
	sz[v] = 1;
	h[v] = hi;
	for (int u : g[v]) {
		dfs1(u, hi + 1);
		sz[v] += sz[u];
	}
}

void dfs2(int v, int pre) {
	ti[v] = tim++;
	st[v] = pre;
	sort(g[v].begin(), g[v].end(), [&](int i, int j) {
		return sz[i] > sz[j];
		});

	if (!g[v].empty()) {
		dfs2(g[v][0], pre);
	}

	for (int i = 1; i < len(g[v]); ++i) {
		dfs2(g[v][i], g[v][i]);
	}

	to[v] = tim;
}


int n;
void upd(int v, int qx) {
	while (v != 0) {
		tree.upd(1, 0, n, ti[st[v]], ti[v] + 1, qx);
		v = p[st[v]];
	}
}

const int inf = 1e6;

int c[N];
vector<int> ord;

void solve() {
	int q;
	cin >> n >> q;

	for (int i = 1; i < n; ++i) {
		cin >> p[i];
		g[--p[i]].push_back(i);
	}

	for (int i = 0; i < n; ++i) {
		cin >> c[i];
	}

	set<pair<int, int>> s;
	s.insert({ 0, 0 });
	while (!s.empty()) {
		int v = s.begin()->second;
		s.erase(s.begin());

		ord.push_back(v);
		for (int u : g[v]) {
			s.insert({ -c[u], u });
		}
	}

	vector<int> ans(n, 0);

	dfs1(0, 0);
	dfs2(0, 0);

	tree.build(1, 0, n, ans);

	for (int i = 0; i < n; ++i) {
		upd(ord[i], 1 - inf);

		ans[ord[i]] = i - max(0, tree.get(1, 0, n, 0, n).x);

		upd(ord[i], inf);
	}

	vector<int> qi(n);
	for (int i = 0; i < q; ++i) {
		cin >> qi[i];
	}

	for (int i = 0; i < q; ++i) {
		cout << ans[qi[i] - 1] << ' ';
	}
	cout << '\n';
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout.precision(30);

	int t = 1;
	//    cin >> t;
	while (t--) solve();
}



