n, m = [int(el) for el in input().split()]
first = set()
second = set()

for _ in range(n):
    first.add(input())
for _ in range(m):
    second.add(input())

print("\n".join(first.intersection(second)))
3900c86750d9db6f14c1ebe6158790f18018914a
<mask token>

<mask token>
for _ in range(n):
    first.add(input())
for _ in range(m):
    second.add(input())
print('\n'.join(first.intersection(second)))

n, m = [int(el) for el in input().split()]
first = set()
second = set()
for _ in range(n):
    first.add(input())
for _ in range(m):
    second.add(input())
print('\n'.join(first.intersection(second)))

n, m = [int(el) for el in input().split()]
first = set()
second = set()

for _ in range(n):
    first.add(input())
for _ in range(m):
    second.add(input())

print("\n".join(first.intersection(second)))