import sys
import random
import heapq
from collections import deque
input = sys.stdin.readline
def fg():
    return int(input())
def fgh():
    return [int(xx) for xx in input().split()]
def tt():
    sys.stdout.flush()
def sd():
    print('Yes')
def df():
    print('No')
'''for __ in range(fg()):
    n, k = fgh()
    a = fgh()
    a = a[::-1]
    dp = [[-23239239293] * (n + 1) for i in range(k + 1)]
    dp[0][0] = 0
    for i in range(k):
        for j in range(1, n + 1):
            dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] - a[i])
        for j in range(n):
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + a[i])
    print(max(dp[k]))
    ans = a[0]
    a.pop(0)
    b = 1
    h = []
    for i in range(k - 1):
        b += 1
        heapq.heappush(h, a[i])
        ans += a[i]
        if b > n:
            b -= 2
            ans -= 2 * h[0]
            heapq.heappop(h)
    print(ans)'''
'''N, n, M, m, k, q = fgh()
a = []
b = []
L1 = 0
for _ in range(n):
    l, i = fgh()
    if _:
        for __ in range(l):
            a.append(i - 1)
    else:
        L1 = l
L2 = 0
for _ in range(m):
    l, o = fgh()
    if _:
        for __ in range(l):
            b.append(o - 1)
    else:
        L2 = l
dp = [[0] * (M + 1) for i in range(N + 1)]
nxt1 = [[N] * k for i in range(N + 1)]
for i in range(N - 1, -1, -1):
    nxt1[i] = nxt1[i + 1][:]
    nxt1[i][a[i]] = i
nxt2 = [[M] * k for i in range(M + 1)]
for i in range(M - 1, -1, -1):
    nxt2[i] = nxt2[i + 1][:]
    nxt2[i][b[i]] = i
for i in range(N - 1, -1, -1):
    for j in range(M - 1, -1, -1):
        dp[i][j] = dp[i + 1][j]
        if nxt1[i + 1][a[i]] != N and nxt2[j][a[i]] != M and dp[nxt1[i + 1][a[i]] + 1][nxt2[j][a[i]] + 1] == 0:
            dp[i][j] -= 1
        if nxt2[j][a[i]] != M and dp[i + 1][nxt2[j][a[i]] + 1] ==  0:
            dp[i][j] += 1
for _ in range(q):
    x, y = fgh()
    
    if dp[x][y]:
        sd()
    else:
        df()'''
n, q = fgh()
p = fgh()
s = fgh()
u = fgh()
son = [[] for i in range(n)]
for i in range(n - 1):
    son[p[i] - 1].append(i + 1)
ans = [n] * n
ans[0] = 0
h = []
for k in son[0]:
    heapq.heappush(h, (-s[k], k))
now = 0
rr = [0]
for i in range(n - 1):
    z = h[0][1]
    heapq.heappop(h)
    ans[z] = i + 1
    for jk in son[z]:
        heapq.heappush(h, (-s[jk], jk))
    now = z
    rr.append(now)
sz = [0] * n
for i in range(n - 1, 0, -1):
    sz[i] += 1
    sz[p[i - 1] - 1] += sz[i]
sz[0] += 1
for _ in range(q):
    y = ans[u[_] - 1]
    ss = ans[u[_] - 1]
    v = u[_] - 1
    pp = [0] * n
    for j in range(y):
        pp[rr[j]] += 1
    for i in range(n - 1, 0, -1):
        pp[p[i - 1] - 1] += pp[i]
    while v != 0:
        d = p[v - 1] - 1
        for uu in son[d]:
            if uu - v:
                ss = min(ss, y - pp[uu])
        v = d
    print(ss, end = ' ')