n, q = map(int, input().split())
p = list(map(int, input().split()))
s = list(map(int, input().split()))
v = list(map(int, input().split()))
par = [1] * n
ln = [0] * n
for i in range(n - 1):
    if p[i] == 1:
        par[i + 1] = i + 1
        ln[i + 1] = 1
    else:
        par[i + 1] = par[i]
        ln[i + 1] = ln[i] + 1
m = {}
prs = []
for j in range(1, n):
    if par[j] not in m:
        m[j] = [s[j]]
        prs.append(j)
    else:
        m[par[j]].append(min(s[j], m[par[j]][-1]))

anss = [0] * q
for x in range(q):
    prt = par[v[x] - 1]
    l = ln[v[x] - 1]
    mn = m[prt][l - 1]
    cnt = [0] * len(prs)
    for i, j in enumerate(prs):
        if j == prt: continue
        left, right = -1, len(m[j])
        while left < right - 1:
            mid = (left + right) // 2
            if m[j][mid] >= mn:
                left = mid
            else:
                right = mid
        cnt[i] = left + 1
    ans = sum(cnt) - max(cnt) + ln[v[x] - 1]
    anss[x] = ans
print(' '.join(anss))
