#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
//#include <cmath>
//#include <numeric>

//#pragma GCC optimize("O3, unroll-loops")
//#pragma GCC target("avx2, avx, lzcnt, popcnt, bmi, bmi2")

using namespace std;

void dfs(int v, vector<vector<int>>& gr, vector<pair<int, int>>& ind, int& cnt) {
	ind[v].first = cnt;
	cnt++;
	for (int u : gr[v]) {
		dfs(u, gr, ind, cnt);
	}
	ind[v].second = cnt;
	cnt++;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin >> n >> k;
	vector<vector<int>> gr(n);
	vector<int> par(n, -1);
	for (int i = 1; i < n; i++) {
		cin >> par[i];
		par[i]--;
		gr[par[i]].push_back(i);
	}
	vector<int> npar(n);
	for (int i = 1; i < n; i++) {
		if (par[i] == 1) {
			npar[i] = i;
		}
		else {
			npar[i] = npar[i - 1];
		}
	}
	vector<int> A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	vector<pair<int, int>> ind(n);
	int timer = 0;
	dfs(0, gr, ind, timer);
	set<pair<int, int>> q;
	set<pair<int, int>> s;
	q.insert({ A[0], 0 });
	vector<int> time(n), temp(n), ans(n);
	int cnt = 0;
	while (!q.empty()) {
		auto it = q.end();
		it--;
		auto elem = *it;
		int v = elem.second;
		for (auto el : s) {
			if (not (ind[el.second].first < ind[v].first && ind[v].second < ind[el.second].second)) {
				ans[v] = el.first;
				break;
			}
		}
		if (v != 0) {
			s.erase({ temp[npar[v]], npar[v] });
			temp[npar[v]--];
			s.insert({ temp[npar[v]], npar[v] });
		}
		q.erase(it);
		time[v] = cnt;
		cnt++;
		for (int u : gr[v]) {
			q.insert({ A[u], u });
		}
	}
	for (int _ = 0; _ < k; _++) {
		int st;
		cin >> st;
		st--;
		cout << time[st] + ans[st] << ' ';
	}
}
