#define _CRT_SECURE_NO_WARNINGS
#ifndef _DEBUG
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <set>
#include <unordered_set>
#include <map>
#include <deque>
#include <queue>
#include <unordered_map>
#include <iomanip>
using namespace std;
using ll = int;
using ld = long double;
using str = string;
using pll = pair<ll, ll>;
auto sd = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(sd);
void sol1() {
	ll n, q;
	cin >> n >> q;
	vector<ll>p(n + 1);
	vector<vector<ll>> g(n + 1);
	for (int i = 2; i <= n; i++) {
		cin >> p[i];
		g[p[i]].emplace_back(i);
	}
	vector<ll> s(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
	}
	vector<ll> min_ans(n + 1, 1e9);
	min_ans[1] = 0;
	
	for (int i = 1; i <= n; i++) {
		ll si = s[i];
		s[i] = 0;
		vector<vector<ll>> g1 = g;
		
		int cnt = n;
		int root = 1;
		int days = 0;
		while (cnt > 1) {
			days++;
			int new_root = 0;
			int mx = -1;
			for (int j : g1[root]) {
				if (s[j] > mx) {
					mx = s[j];
					new_root = j;
				}
			}
			while (!g1[root].empty()) {
				if (g1[root].back() != new_root) {
					g1[new_root].emplace_back(g1[root].back());
				}
				g1[root].pop_back();
			}
			
			min_ans[new_root] = min(min_ans[new_root],(ll) days);
			cnt--;
			root = new_root;
		}
		s[i] = si;
	}
	vector<vector<ll>> g1 = g;

	int cnt = n;
	int root = 1;
	int days = 0;
	while (cnt > 1) {
		days++;
		int new_root = 0;
		int mx = -1;
		for (int j : g1[root]) {
			if (s[j] > mx) {
				mx = s[j];
				new_root = j;
			}
		}
		while (!g1[root].empty()) {
			if (g1[root].back() != new_root) {
				g1[new_root].push_back(g1[root].back());
			}
			g1[root].pop_back();
		}
		min_ans[new_root] = min(min_ans[new_root], (ll)days);
		cnt--;
	}

	for (int j = 0; j < q; j++) {
		int vi; cin >> vi;
		cout << min_ans[vi] << " ";
	}
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	ll t1 = 1;
	//cin >> t1;
	for (int o_ = 0; o_ < t1; o_++) sol1();
}

