#ifdef _DEBUG
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define int int64_t

vector<int> s;

class Cmp {
public:
	bool operator()(int i, int j) const {
		return s[i] > s[j] || s[i] == s[j] && i > j;
	}
};

vector<set<int>> g;
vector<set<int>> gcur;
vector<set<int, Cmp>> depth;
vector<int> d, p;

void dfs(int v, int pp, int pr = -1) {
	d[v] = pr == -1 ? 0 : d[pr] + 1;
	p[v] = pr;
	depth[d[v]].insert(v);
	for (int to : gcur[v]) {
		if (to == pr) continue;
		if (to == pp) continue;
		dfs(to, pp, v);
	}
}

void solve() {
	int n, q;
	cin >> n >> q;
	g.resize(n);
	for (int i = 1; i < n; ++i) {
		int x;
		cin >> x;
		--x;
		g[x].insert(i);
	}
	s.resize(n);
	p.resize(n);
	d.resize(n);
	depth.resize(n);
	for (int& i : s) cin >> i;
	p[0] = -1;

	while (q--) {
		int v;
		cin >> v; --v;
		gcur = g;
		int cur_root = 0, cnt = 0;
		int prev_root = 0;
		while (true) {
			for (int i = 0; i < n; ++i) depth[i].clear();
			if (v == cur_root) {
				cout << cnt << ' ';
				break;
			}
			dfs(cur_root, p[cur_root]);
			if (d[v] == 1 && (*depth[1].begin() == v || (int(depth[1].size()) >= 2 && *(++depth[1].begin()) == v))) {
				cout << cnt + 1 << ' ';
				break;
			}
			int root = cur_root;
			cur_root = *depth[1].begin();
			for (int to : gcur[root]) {
				gcur[cur_root].insert(to);
			}
			gcur[cur_root].erase(root);
			gcur[cur_root].erase(cur_root);
			depth[1].erase(depth[1].begin());
			++cnt;
		}
	}
	return;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int test = 1;
	//cin >> test;

	while (test--) {
		solve();
	}

	return 0;
}