n = int(eval(input()))

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



q = eval(input())

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



cnt = 0



for i in T:

    left = 0

    right = n

    while left < right:

        mid = (left + right) // 2

        if S[mid] == i:

            cnt += 1

            break

        elif i < S[mid]:

            right = mid

        else:

            left = mid + 1



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

S = tuple(map(int, input().split(' ')))



q = eval(input())

T = tuple(map(int, input().split(' ')))



cnt = 0



for i in T:

    left = 0

    right = n

    while left < right:

        mid = (left + right) // 2

        if S[mid] == i:

            cnt += 1

            break

        elif i < S[mid]:

            right = mid

        else:

            left = mid + 1



print(cnt)
n = int(eval(input()))
S = list(map(int, input().split(" ")))
q = eval(input())
T = list(map(int, input().split(" ")))
cnt = 0
for i in T:
    left = 0
    right = n
    while left < right:
        mid = (left + right) // 2
        if S[mid] == i:
            cnt += 1
            break
        elif i < S[mid]:
            right = mid
        else:
            left = mid + 1
print(cnt)

n = int(eval(input()))
S = tuple(map(int, input().split(" ")))
q = eval(input())
T = tuple(map(int, input().split(" ")))
cnt = 0
for i in T:
    left = 0
    right = n
    while left < right:
        mid = (left + right) // 2
        if S[mid] == i:
            cnt += 1
            break
        elif i < S[mid]:
            right = mid
        else:
            left = mid + 1
print(cnt)

-S = list(map(int, input().split(" "))) +S = tuple(map(int, input().split(" "))) -T = list(map(int, input().split(" "))) +T = tuple(map(int, input().split(" ")))