rotas = int(input())
dect = {}
for i in range(rotas):
    dect[input()] = 0
data = input()
while data != "END":
    if data in dect:
        dect.pop(data)
    data = input()
print(len(dect))
for key in sorted(dect.keys()):
    print(key)

fef0d4941da6211115720d10d316eb35b393ed5c
<mask token>

<mask token>
for i in range(rotas):
    dect[input()] = 0
<mask token>
while data != 'END':
    if data in dect:
        dect.pop(data)
    data = input()
print(len(dect))
for key in sorted(dect.keys()):
    print(key)

rotas = int(input())
dect = {}
for i in range(rotas):
    dect[input()] = 0
data = input()
while data != 'END':
    if data in dect:
        dect.pop(data)
    data = input()
print(len(dect))
for key in sorted(dect.keys()):
    print(key)

rotas = int(input())
dect = {}
for i in range(rotas):
    dect[input()] = 0
data = input()
while data != "END":
    if data in dect:
        dect.pop(data)
    data = input()
print(len(dect))
for key in sorted(dect.keys()):
    print(key)
