import sys
read_line = sys.stdin.readline
n, m = map(int, read_line().split())
A = set()
B = set()
A.update(list(read_line().lower().split()))
B.update(list(read_line().lower().split()))
intersection_len = len(A.intersection(B))
union_len = len(A.union(B))
print(f"{intersection_len}\n{union_len}")