on = set()
for i in range(int(input())):
    name, check = input().split()
    if check == 'enter':
        on.add(name)
    else:
        on.remove(name)
for nm in sorted(on, reverse=True):
    print(nm)

8cec36fc8abc6578aee5520336a59b040812aa6a
<mask token>

<mask token>
for i in range(int(input())):
    name, check = input().split()
    if check == 'enter':
        on.add(name)
    else:
        on.remove(name)
for nm in sorted(on, reverse=True):
    print(nm)

on = set()
for i in range(int(input())):
    name, check = input().split()
    if check == 'enter':
        on.add(name)
    else:
        on.remove(name)
for nm in sorted(on, reverse=True):
    print(nm)
