# -*- coding: utf-8 -*-
n = input()
l = []
tail = 0
for i in xrange(n):
    cmd = raw_input().split()
    if cmd[0] == "insert":
        l.append(cmd[1])
    elif cmd[0] == "delete":
        try:
            l.pop(len(l) - l[::-1].index(cmd[1]) -1)
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        l.pop()
    elif cmd[0] == "deleteLast":
        tail += 1

print " ".join(l[tail:][::-1]) n = input() n input() input l = [] l [] tail = 0 tail 0 for i in xrange(n):
    cmd = raw_input().split()
    if cmd[0] == "insert":
        l.append(cmd[1])
    elif cmd[0] == "delete":
        try:
            l.pop(len(l) - l[::-1].index(cmd[1]) -1)
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        l.pop()
    elif cmd[0] == "deleteLast":
        tail += 1 i xrange(n) xrange n cmd = raw_input().split() cmd raw_input().split() ().split () raw_input split if cmd[0] == "insert":
        l.append(cmd[1])
    elif cmd[0] == "delete":
        try:
            l.pop(len(l) - l[::-1].index(cmd[1]) -1)
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        l.pop()
    elif cmd[0] == "deleteLast":
        tail += 1 cmd[0] == "insert" cmd[0] cmd 0 "insert" l.append(cmd[1]) l.append l append cmd[1] cmd 1 elif cmd[0] == "delete":
        try:
            l.pop(len(l) - l[::-1].index(cmd[1]) -1)
        except ValueError:
            pass
     cmd[0] == "delete" cmd[0] cmd 0 "delete" try:
            l.pop(len(l) - l[::-1].index(cmd[1]) -1)
        except ValueError:
            pass
     except ValueError:
            pass
     l.pop(len(l) - l[::-1].index(cmd[1]) -1) l.pop l pop len(l) - l[::-1].index(cmd[1]) -1 len(l) - l[::-1].index(cmd[1]) len(l) len l l[::-1].index(cmd[1]) [::-1].index [::-1] l ::-1 -1 index cmd[1] cmd 1 1 elif cmd[0] == "deleteFirst":
        l.pop()
     cmd[0] == "deleteFirst" cmd[0] cmd 0 "deleteFirst" l.pop() l.pop l pop elif cmd[0] == "deleteLast":
        tail += 1 cmd[0] == "deleteLast" cmd[0] cmd 0 "deleteLast" tail += 1 tail 1 print " ".join(l[tail:][::-1]) " ".join " " join l[tail:][::-1] [tail:] l tail: tail ::-1 -1 l = [] [] l cmd = raw_input().split() raw_input().split() cmd tail = 0 0 tail n = input() input() n tail += 1 1 tail
# -*- coding: utf-8 -*-
n = input()
l = []
tail = 0
for i in xrange(n):
    cmd = raw_input().split()
    if cmd[0] == "insert":
        l.append(cmd[1])
    elif cmd[0] == "delete":
        try:
            l.pop(len(l) - l[::-1].index(cmd[1]) -1)
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        l.pop()
    elif cmd[0] == "deleteLast":
        tail += 1

print " ".join(l[tail:][::-1])