import sys
import random
import heapq
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 = []
for _ in range(n):
    l, i = fgh()
    for __ in range(l):
        a.append(i - 1)
for _ in range(m):
    l, o = fgh()
    for __ in range(l):
        b.append(o - 1)
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
for j in range(n):
    s1 = s[:]
    s1[j] = 0
    son1 = [[] for i in range(n)]
    for i in range(n):
        son1[i] = son[i][:]
    now = 0
    for i in range(n - 1):
        mx = -1
        z = -1
        for j in son1[now]:
            if s1[j] > mx:
                mx = s1[j]
                z = j
        ans[z] = min(ans[z], i + 1)
        for j in son1[now]:
            if j - z:
                son1[z].append(j)
        son1[now] = []
        now = z
for _ in range(q):
    print(ans[u[_] - 1], end = ' ')