Created
May 24, 2022 09:42
-
-
Save mym0404/d1b0106d62eb1e0511bba68c58e416db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N, M = map(int, input().split()) | |
all_names = set() | |
name1 = set() | |
name2 = set() | |
for _ in range(N): | |
name = input() | |
name1.add(name) | |
all_names.add(name) | |
answer = [] | |
for _ in range(M): | |
name = input() | |
name2.add(name) | |
all_names.add(name) | |
for name in all_names: | |
if name in name1 and name in name2: | |
answer.append(name) | |
answer.sort() | |
print(len(answer)) | |
for name in answer: | |
print(name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment