#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<functional>
#include<queue>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, q;
	cin >> n >> q;
	vector<vector<int>> g(n);
	for (int i = 1; i < n; ++i) {
		int p;
		cin >> p;
		p--;
		g[p].push_back(i);
		g[i].push_back(p);
	}
	vector<int> s(n);
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
	}
	vector<int> ans(n, 1e9);
	ans[0] = 0;
	priority_queue<pair<int, int>> Q;
	int x = 0;
	for (int i = 0; i < n; ++i) {
		swap(s[i], x);
		Q.emplace(s[0], 0);
		vector<int> visited(n);
		int cnt = 0;
		while (!Q.empty()) {
			int r = Q.top().second; Q.pop();
			visited[r] = 1;
			ans[r] = min(ans[r], cnt);
			for (auto u : g[r]) {
				if (!visited[u]) {
					Q.emplace(s[u], u);
				}
			}
			cnt++;
		}
		swap(s[i], x);
	}
	for (int i = 0; i < q; ++i) {
		int x;
		cin >> x;
		x--;
		cout << ans[x] << ' ';
	}
	return 0;
}