N = int(eval(input()))

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

Q = int(eval(input()))

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



cnt = 0

for i in T:

    for j in S:

        if i == j:

            cnt += 1

            break

print(cnt)
n = int(eval(input()))

S = set([int(i) for i in input().split()])

q = int(eval(input()))

T = set([int(i) for i in input().split()])

print((len( S & T )))
N = int(eval(input()))
S = list(map(int, input().split()))
Q = int(eval(input()))
T = list(map(int, input().split()))
cnt = 0
for i in T:
    for j in S:
        if i == j:
            cnt += 1
            break
print(cnt)

n = int(eval(input()))
S = set([int(i) for i in input().split()])
q = int(eval(input()))
T = set([int(i) for i in input().split()])
print((len(S & T)))

-N = int(eval(input())) -S = list(map(int, input().split())) -Q = int(eval(input())) -T = list(map(int, input().split())) -cnt = 0 -for i in T: -    for j in S: -        if i == j: -            cnt += 1 -            break -print(cnt) +n = int(eval(input())) +S = set([int(i) for i in input().split()]) +q = int(eval(input())) +T = set([int(i) for i in input().split()]) +print((len(S & T)))