//#pragma GCC optimize("O3");
//#pragma GCC target("avx, avx2")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define ALL(X) (X.begin()), (X.end())
#define sz(X) (int)(X.size())

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned int ui;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

vector<int> color;

void paint(int v, vector<vector<int>>& g, int clr) {
	color[v] = clr;
	for (int x : g[v]) {
		paint(x, g, clr);
	}
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   	int n, q;
   	cin >> n >> q;
   	vector<int> p(n);
   	p[0] = 0;
   	vector<vector<int>> g(n);
   	for (int i = 0; i < n - 1; ++i) {
   		cin >> p[i + 1];
   		--p[i + 1];
   		g[p[i + 1]].emplace_back(i + 1);
   	}
   	vector<int> a(n);
   	for (int i = 0; i < n; ++i) {
   		cin >> a[i];
   	} 
   	color.resize(n);
   	int tmp = 1;
   	for (int x : g[0]) {
   		paint(x, g, tmp++);
   	}
   	/*for (int i = 0; i < n; ++i) {
   		cout << color[i] << " ";
   	}
   	cout << "\n";*/
   	vector<int> maxv(n, 0);
   	vector<int> cnt(n, 0);
   	vector<int> clr_cnt(tmp, 0);
   	pair<int, int> v1 = {0, 0}, v2 = {0, 0};
   	set<pair<int, int>, greater<pair<int, int>>> s;
   	s.insert({a[0], 0});
   	int time = 0;
   	vector<int> ans(n);
   	while (!s.empty()) {
   		int v = s.begin()->second;
   		s.erase(s.begin());
   		for (int x : g[v]) {
   			s.emplace(a[x], x);
   		}
   		int d = maxv[p[v]];
   		//cout << "maxv: " << d << "\n";	
   		if (v1.second == color[v]) {
   			d = max(d, v2.first);
   		} else {
   			d = max(d, v1.first);
   		}
   		//cout << "v: " << v << " d: " << d << " time: " << time << "\n";
   		ans[v] = time - d;
   		if (v != 0) {
	   		++clr_cnt[color[v]];
	   		if (clr_cnt[color[v]] > v1.first) {
	   			if (color[v] != v1.second) {
	   				v2 = v1;
	   			}
	   			v1.first = clr_cnt[color[v]];
	   			v1.second = color[v];
	   		} else if (clr_cnt[color[v]] > v2.first) {
	   			v2.first = clr_cnt[color[v]];
	   			v2.second = color[v]; 
	   		}
	   		while (v != 0) {
	   			++cnt[v];
	   			maxv[p[v]] = max(maxv[p[v]], cnt[v]);
	   			v = p[v];
	   		}
   		}
   		++time;
   	}		
   	while (q--) {
   		int x;
   		cin >> x;
   		cout << ans[x - 1] << " ";	
   	}
   	cout << "\n";
   	/*for (int i = 0; i < n; ++i) {
   		cout << ans[i] << " ";
   	}*/
    return 0;
}
