n, m = map(int, input().split()) #듣도 못한, 보도 못한
nosee = set()
for _ in range(n):
nosee.add(input())
noheard = set()
for _ in range(m):
noheard.add(input())
answer = nosee.intersection(noheard)
answer = list(answer)
answer.sort()
print(len(answer))
print(*answer,sep='\n')