#define _CRT_SECURE_NO_WARNINGS


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>


using namespace std;
using ll=long long;
const ll inf = 1e6;


ll p[300001];
ll s[300001];
vector<vector<ll> > g(300001);
ll num[300001];
ll pos[300001];
ll sz[300001];
ll head[300001];
ll euler[300001];
ll qq[300001];
ll ans[300001];
ll t = 0;
void dfs1(int x) {
	sz[x] = 1;
	for (int i = 0;i<g[x].size();++i) {
		dfs1(g[x][i]);
		sz[x] += sz[g[x][i]];
		if (sz[g[x][i]] > sz[g[x][0]]) {
			swap(g[x][i], g[x][0]);
		}
	}
}
void dfs2(int x) {
	++t;
	euler[t] = x;
	if (g[x].size() > 0) {
		head[g[x][0]] = head[x];
		dfs2(g[x][0]);
		for (int i = 1; i < g[x].size(); ++i) {
			head[g[x][i]] = g[x][i];
			dfs2(g[x][i]);
		}
	}
}
struct segtree {
	int lb, rb;
	int mx = 0;
	int add = 0;
	segtree* l = 0, *r = 0;
	segtree(int lb, int rb) :lb(lb), rb(rb) {
		if (lb < rb) {
			int m = lb + (rb - lb) / 2;
			l = new segtree(lb, m);
			r = new segtree(m+1, rb);
		}
	}
	void push() {
		if (add != 0) {
			mx += add;
			if (lb < rb) {
				l->add += add;
				r->add += add;
			}
			add = 0;
		}
	}
	void upd(int lq, int rq, int val) {
		push();
		if (min(rq, rb) < max(lb, lq)) {
			return;
		}
		if (lb >= lq && rb <= rq) {
			mx += val;
			if (lb < rb) {
				l->add += val;
				r->add += val;
			}
			return;
		}
		l->upd(lq, rq,val);
		r->upd(lq, rq,val);
		mx = max(l->mx, r->mx);
	}
	int get(int lq, int rq) {
		push();
		if (min(rq, rb) < max(lb, lq)) {
			return 0;
		}
		if (lb >= lq && rb <= rq) {
			return mx;
		}
		return max(l->get(lq, rq), r->get(lq, rq));
	}
};
int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n, q;
	cin >> n >> q;
	p[1] = -1;
	for (int i = 2; i <= n; ++i) {
		cin >> p[i];
		g[p[i]].push_back(i);
	}
	for (int i = 1; i <= n; ++i) {
		cin >> s[i];
		head[i] = i;
	}
	ll nach = 1;
	num[1] = 1;
	pos[1] = 1;
	set<pair<ll,ll>> t;
	for (int i = 0; i < g[1].size(); ++i) {
		t.insert({ s[g[1][i]],g[1][i] });
	}
	ll numnum = 1;
	while (t.size() > 0) {
		++numnum;
		auto it = t.end();
		--it;
		pair<ll, ll> f = *it;
		nach = f.second;
		pos[numnum] = nach;
		num[nach] = numnum;
		t.erase(it);
		for (int i = 0; i < g[nach].size(); ++i) {
			t.insert({ s[g[nach][i]],g[nach][i] });
		}
	}
	dfs1(1);
	dfs2(1);
	segtree seg(1, n);
	for (int i = 1; i <= q; ++i) {
		ll v;
		cin >> v;
		qq[pos[v]] = i;
	}
	for (int i = 1; i <= n; ++i) {
		int h = pos[i];
		while (h != -1) {
			int k = head[h];
			seg.upd(euler[k], euler[h], -inf);
			h = p[k];
		}
		int kol = seg.get(1, n);
		if (qq[i] != 0) {
			ans[qq[i]] = min(i-1,i - kol-1);
		}
		h = pos[i];
		while (h != -1) {
			int k = head[h];
			seg.upd(euler[k], euler[h], inf+1);
			h = p[k];
		}
	}
	for (int i = 1; i <= q; ++i) {
		cout << ans[i] << " ";
	}
}