N = int(eval(input()))

A = list(map(int,input().split()))

A.insert(0,0)

A.insert(0,0)

G = {i:[] for i in range(1,N+1)}

for i in range(2,N+1):

    G[A[i]].append(i)

for i in range(1,N+1):

    print((len(G[i])))
N = int(eval(input()))

A = list(map(int,input().split()))

A.insert(0,0)

A.insert(0,0)

C = {i:0 for i in range(1,N+1)}

for i in range(2,N+1):

    a = A[i]

    C[a] += 1

for i in range(1,N+1):

    print((C[i]))
N = int(eval(input()))
A = list(map(int, input().split()))
A.insert(0, 0)
A.insert(0, 0)
G = {i: [] for i in range(1, N + 1)}
for i in range(2, N + 1):
    G[A[i]].append(i)
for i in range(1, N + 1):
    print((len(G[i])))

N = int(eval(input()))
A = list(map(int, input().split()))
A.insert(0, 0)
A.insert(0, 0)
C = {i: 0 for i in range(1, N + 1)}
for i in range(2, N + 1):
    a = A[i]
    C[a] += 1
for i in range(1, N + 1):
    print((C[i]))

-G = {i: [] for i in range(1, N + 1)} +C = {i: 0 for i in range(1, N + 1)} -    G[A[i]].append(i) +    a = A[i] +    C[a] += 1 -    print((len(G[i]))) +    print((C[i]))