N = int(eval(input()))

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

T = int(eval(input()))

Q = [int(x) for x in input().split()]



c = set()



for s in S:

    for q in Q:

        if s == q:

            c.add(s)



print((len(c)))

N = int(eval(input()))

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

T = int(eval(input()))

Q = [int(x) for x in input().split()]



c = 0



def seach(A, n, key):

    i = 0

    A = A + [key]

    while A[i] != key:

        i += 1

    return i != n



for q in Q:

    if seach(S, N, q):

        c += 1

        

print(c)

N = int(eval(input()))
S = [int(x) for x in input().split()]
T = int(eval(input()))
Q = [int(x) for x in input().split()]
c = set()
for s in S:
    for q in Q:
        if s == q:
            c.add(s)
print((len(c)))

N = int(eval(input()))
S = [int(x) for x in input().split()]
T = int(eval(input()))
Q = [int(x) for x in input().split()]
c = 0


def seach(A, n, key):
    i = 0
    A = A + [key]
    while A[i] != key:
        i += 1
    return i != n


for q in Q:
    if seach(S, N, q):
        c += 1
print(c)

-c = set() -for s in S: -    for q in Q: -        if s == q: -            c.add(s) -print((len(c))) +c = 0 + + +def seach(A, n, key): +    i = 0 +    A = A + [key] +    while A[i] != key: +        i += 1 +    return i != n + + +for q in Q: +    if seach(S, N, q): +        c += 1 +print(c)