// 1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,avx,avx2")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <immintrin.h>
#include <queue>

using ll = long long;
using ld = long double;
using namespace std;

const int MAXN = (1 << 19), SIZE = 2 * MAXN + 1, MAXV = 3e5 + 10;
int upd[SIZE], mx[SIZE];

int ql, qr, qt;
void push(int v, int l, int r)
{
	if (upd[v] != 0)
	{
		mx[v] += upd[v];
		if (r - l != 1)
		{
			upd[2 * v + 1] += upd[v];
			upd[2 * v + 2] += upd[v];
		}
		upd[v] = 0;
	}
}

void update(int v, int l, int r)
{
	push(v, l, r);
	if (ql >= r || qr <= l)
		return;
	if (ql <= l && r <= qr)
	{
		upd[v] += qt;
		push(v, l, r);
		return;
	}
	update(2 * v + 1, l, (l + r) >> 1);
	update(2 * v + 2, (l + r) >> 1, r);
	mx[v] = max(mx[2 * v + 1], mx[2 * v + 2]);
}

void segment(int v, int l, int r)
{
	push(v, l, r);
	if (ql >= r || qr <= l)
		return;
	if (ql <= l && r <= qr)
	{
		qt = max(qt, mx[v]);
		return;
	}
	segment(2 * v + 1, l, (l + r) >> 1);
	segment(2 * v + 2, (l + r) >> 1, r);
}

vector <int> g[MAXV];
int sz[MAXV], tin[MAXV], tout[MAXV], pp[MAXV], p[MAXV], tm = 0;

void dfs1(int v)
{
	sz[v] = 1;
	for (auto& u : g[v])
	{
		dfs1(u);
		sz[v] += sz[u];
	}
}

void dfs2(int v)
{
	tin[v] = tm++;
	if (g[v].empty())
	{
		tout[v] = tm;
		return;
	}
	sort(g[v].begin(), g[v].end(), [](int a, int b) {return sz[a] > sz[b]; });
	int u = g[v][0];
	for (auto& i : g[v])
	{
		pp[i] = (i == u ? pp[v] : i);
		dfs2(i);
	}
	tout[v] = tm;
}

void add(int v, int k)
{
	qt = k;
	while (v != -1)
	{
		ql = tin[pp[v]];
		qr = tin[v] + 1;
		update(0, 0, MAXN);
		v = p[pp[v]];
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ooshp 2024-2025 zakluchitelnuy tur
	// Code is written by Mark_Pr (c) 2025
	memset(upd, 0, sizeof(upd));
	memset(mx, 0, sizeof(mx));
	memset(p, -1, sizeof(p));
	memset(tin, 0, sizeof(tin));
	memset(tout, 0, sizeof(tout));
	memset(pp, -1, sizeof(pp));
	memset(sz, 0, sizeof(sz));
	int n, q;
	cin >> n >> q;
	vector <int> s(n);
	for (size_t i = 1; i < n; i++)
	{
		cin >> p[i];
		p[i]--;
		g[p[i]].push_back(i);
	}
	dfs1(0);
	dfs2(0);
	for (auto& i : s)
	{
		cin >> i;
	}
	vector <int> t(n);
	vector <int> ans(n);
	tm = 0;
	priority_queue<pair<int, int>> pq;
	pq.emplace(0, 0);
	while (!pq.empty())
	{
		int v = pq.top().second;
		pq.pop();
		t[v] = tm++;
		add(v, -1e8);
		ql = 0;
		qr = n;
		qt = 0;
		segment(0, 0, MAXN);
		ans[v] = t[v] - qt;
		add(v, 1e8);
		add(v, 1);
		for (auto& i : g[v])
		{
			pq.emplace(s[i], i);
		}
	}
	for (size_t i = 0; i < q; i++)
	{
		int v;
		cin >> v;
		v--;
		cout << ans[v] << ' ';
	}
	return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
