#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <random>
#include <chrono>
using namespace std;
typedef int ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
ll n, q;
vector<vector<ll>> g, x;
vector<multiset<ll>> mn;
vector<ll> ans, pos;
void z(ll v) {
	for (ll j = 0; j < x[v].size(); ++j) mn[j].insert(x[v][j]);
}
void dz(ll v) {
	for (ll j = 0; j < x[v].size(); ++j) mn[j].erase(mn[j].find(x[v][j]));
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> q;
	vector<ll> p(n, -1), a(n), y;
	pos.resize(n);
	g.resize(n);
	for (ll i = 1; i < n; ++i) cin >> p[i], g[--p[i]].push_back(i);
	for (ll i = 0; i < n; ++i) cin >> a[i];
	set<pair<ll, ll>> s = { {-a[0], 0} };
	for (ll i = 0; i < n; ++i) {
		ll v = (*s.begin()).second;
		s.erase(s.begin());
		pos[v] = (ll)y.size();
		y.push_back(v);
		for (auto u : g[v]) s.insert({ -a[u], u });
	}
	x.resize(n);
	for (ll i = 0; i < n; ++i) {
		for (ll v = i; v != -1; v = p[v]) x[v].push_back(pos[i]);
	}
	mn.assign(n, { n });
	for (ll i = 0; i < n; ++i) {
		sort(x[i].begin(), x[i].end());
		z(i);
	}
	while (q--) {
		ll v;
		cin >> v;
		--v;
		for (ll u = v; u != -1; u = p[u]) dz(u);
		ll l = 0, r = n;
		while (r - l > 1) {
			ll m = (l + r) / 2;
			if ((*mn[m - 1].begin()) < pos[v]) l = m;
			else r = m;
		}
		cout << pos[v] - l << " ";
		for (ll u = v; u != -1; u = p[u]) z(u);
	}
	cout << endl;
	return 0;
}