#pragma GCC optimize("O3")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <random>
#include <string>

using namespace std;
#define int long long
using ll = long long;
using ld = long double;

#define dbg(x) cerr << #x << ": " << x << "\n"

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int n, q;
	cin >> n >> q;
	vector<vector<int>> a;
	int sz = 0;
	vector<int> ind(n), height(n);
	for (int v = 1; v < n; v++) {
		int p;
		cin >> p;
		p--;
		if (p == 0) {
			a.push_back(vector<int>(1));
			sz++;
			a[sz - 1][0] = v;
			ind[v] = sz - 1;
			height[v] = 1;
		}
		else {
			a[ind[p]].push_back(v);
			ind[v] = ind[p];
			height[v] = height[p] + 1;
		}
	}
	vector<int> s(n);
	for (int i = 0; i < n; i++) cin >> s[i];
	vector<vector<int>> pref(sz);
	for (int iter = 0; iter < sz; iter++) {
		int sz2 = a[iter].size();
		pref[iter] = vector<int>(sz2);
		for (int i = 0; i < sz2; i++) {
			pref[iter][i] = s[a[iter][i]];
			if (i != 0) pref[iter][i] = min(pref[iter][i], pref[iter][i - 1]);
		}
	}
	while (q--) {
		int v;
		cin >> v;
		v--;
		if (v == 0) {
			cout << "0 ";
		}
		int branch = ind[v];
		int worst = pref[branch][height[v] - 1];
		int ans = height[v];
		for (int cand = 0; cand < sz; cand++) {
			if (cand == branch || pref[cand][0] < worst) continue;
			int sz2 = pref[cand].size();
			int l = 0, r = sz2;
			while (r - l > 1) {
				int mid = (l + r) / 2;
				if (pref[cand][mid] > worst) {
					l = mid;
				}
				else {
					r = mid;
				}
			}
			ans += l + 1;
		}
		cout << ans << ' ';
	}
}
