n = int(eval(input()))

s = [(input().split()) for _ in range(n)]

m = int(eval(input()))

t = [(input().split()) for _ in range(m)]

ans = 0



for i in range(n):

    ans = max(ans, s.count(s[i]) - t.count(s[i]))



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

s = [(input().split()) for _ in range(n)]

m = int(eval(input()))

t = [(input().split()) for _ in range(m)]

ans = 0



for i in s:

    ans = max(ans, s.count(i) - t.count(i))



print(ans)
n = int(eval(input()))
s = [(input().split()) for _ in range(n)]
m = int(eval(input()))
t = [(input().split()) for _ in range(m)]
ans = 0
for i in range(n):
    ans = max(ans, s.count(s[i]) - t.count(s[i]))
print(ans)

n = int(eval(input()))
s = [(input().split()) for _ in range(n)]
m = int(eval(input()))
t = [(input().split()) for _ in range(m)]
ans = 0
for i in s:
    ans = max(ans, s.count(i) - t.count(i))
print(ans)

-for i in range(n): -    ans = max(ans, s.count(s[i]) - t.count(s[i])) +for i in s: +    ans = max(ans, s.count(i) - t.count(i))