n = int(eval(input()))

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

q = int(eval(input()))

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



C = []

for s in S:

  for t in T:

    if s == t and not s in C: C.append(s)

print((len(C)))
n = int(eval(input()))

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

q = int(eval(input()))

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



C = 0

for t in T:

  for s in S:

    if s == t:

      C += 1

      break

print(C)
n = int(eval(input()))
S = list(map(int, input().split()))
q = int(eval(input()))
T = list(map(int, input().split()))
C = []
for s in S:
    for t in T:
        if s == t and not s in C:
            C.append(s)
print((len(C)))

n = int(eval(input()))
S = list(map(int, input().split()))
q = int(eval(input()))
T = list(map(int, input().split()))
C = 0
for t in T:
    for s in S:
        if s == t:
            C += 1
            break
print(C)

-C = [] -for s in S: -    for t in T: -        if s == t and not s in C: -            C.append(s) -print((len(C))) +C = 0 +for t in T: +    for s in S: +        if s == t: +            C += 1 +            break +print(C)