#include <bits/stdc++.h>

using namespace std;

using ll = long long;
#define x first
#define y second

void solve();

int main() {
	cin.tie(nullptr)->sync_with_stdio(false);
	cout << fixed << setprecision(30);
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}

struct segment_tree {
	vector<int> st;
	size_t sz;
	segment_tree(int n = 0) {
		sz = 1;
		while (sz < n) sz <<= 1;
		st.resize(2 * sz, 0);
	}
	void update(int i, int v) {
		i += sz;
		while (i) {
			st[i] = max(st[i], v);
			i >>= 1;
		}
	}
	int get(int l, int r) {
		l += sz; r += sz;
		int res = 0;
		while (l <= r) {
			if (l & 1) res = max(res, st[l++]);
			if (~r & 1) res = max(res, st[r--]);
			l >>= 1;
			r >>= 1;
		}
		return res;
	}
};



const int N = 300300;
vector<int> g[N];
segment_tree st[N];
int val[N], ans[N], sz[N], num[N], pr[N];

void calc_sz(int s) {
	sz[s] = 1;
	for (int i : g[s]) {
		calc_sz(i);
		sz[s] += sz[i];
	}
}

void hld_prepare(int s) {
	for (int &i : g[s]) {
		hld_prepare(i);
		if (sz[i] > sz[g[s][0]]) {
			swap(i, sz[g[s][0]]);
		}
	}
}

void calc_num(int s) {
	int nm = 0;
	for (int i : g[s]) {
		calc_num(i);
		num[i] = nm++;
	}
}

void solve() {
	int n, q;
	cin >> n >> q;
	pr[0] = -1;
	for (int i = 1; i < n; i++) {
		int p;
		cin >> p; p--;
		g[p].push_back(i);
		pr[i] = p;
	}
	for (int i = 0; i < n; i++) {
		cin >> val[i]; val[i] = n - val[i];
	}
	calc_sz(0);
	hld_prepare(0);
	calc_num(0);
	for (int i = 0; i < n; i++) {
		st[i] = segment_tree(g[i].size());
	}
	set<pair<int, int>> now;
	now.emplace(val[0], 0);
	int iter = 0;
	while (!now.empty()) {
		auto [tr, s] = *now.begin();
		now.erase(now.begin());
		for (int i : g[s]) {
			now.emplace(val[i], i);
		}
		int cur = s;
		while (cur) {
			ans[s] = max({ans[s], st[pr[cur]].get(0, num[cur] - 1), st[pr[cur]].get(num[cur] + 1, g[pr[cur]].size() - 1)});
			st[pr[cur]].update(num[cur], st[pr[cur]].get(num[cur], num[cur]) + 1);
			cur = pr[cur];
		}
		ans[s] = iter - ans[s];
		iter++;
	}
	while (q--) {
		int v;
		cin >> v; v--;
		cout << ans[v] << ' ';
	}
	cout << '\n';
}
