<reponame>PawarAditi/HackerRank
stamps = set()
for _ in range(int(input())):
    stamps.add(input())
print(len(stamps))

stamps = set()
for _ in range(int(input())):
    stamps.add(input())
print(len(stamps))