n, m = map(int, input().split())
a = []
b = []
for _ in range(n):
    a.append(input())
for _ in range(m):
    b.append(input())
c = sorted(list(set(a) & set(b)))
print(len(c))
for item in c:
    print(item)

c43691bfa667ccf96195c3fe1427e893b378e9b0
<mask token>

<mask token>
for _ in range(n):
    a.append(input())
for _ in range(m):
    b.append(input())
<mask token>
print(len(c))
for item in c:
    print(item)

n, m = map(int, input().split())
a = []
b = []
for _ in range(n):
    a.append(input())
for _ in range(m):
    b.append(input())
c = sorted(list(set(a) & set(b)))
print(len(c))
for item in c:
    print(item)
