import sys
from collections import deque
readline = sys.stdin.readline
dq = deque()
for _ in range(int(input())):
    c = readline().split()
    if c[0] == "deleteFirst":
        del dq[0]
    elif c[0] == "deleteLast":
        del dq[-1]
    else:
        if c[0] == "insert":
            dq.appendleft(c[1])
        elif c[0] == "delete":
            if c[1] in dq:
                dq.remove(c[1])
print(*dq)
 import sys sys from collections import deque readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline dq = deque() dq deque() deque for _ in range(int(input())):
    c = readline().split()
    if c[0] == "deleteFirst":
        del dq[0]
    elif c[0] == "deleteLast":
        del dq[-1]
    else:
        if c[0] == "insert":
            dq.appendleft(c[1])
        elif c[0] == "delete":
            if c[1] in dq:
                dq.remove(c[1]) _ range(int(input())) range int(input()) int input() input c = readline().split() c readline().split() ().split () readline split if c[0] == "deleteFirst":
        del dq[0]
    elif c[0] == "deleteLast":
        del dq[-1]
    else:
        if c[0] == "insert":
            dq.appendleft(c[1])
        elif c[0] == "delete":
            if c[1] in dq:
                dq.remove(c[1]) c[0] == "deleteFirst" c[0] c 0 "deleteFirst" del dq[0] dq[0] dq 0 elif c[0] == "deleteLast":
        del dq[-1]
     c[0] == "deleteLast" c[0] c 0 "deleteLast" del dq[-1] dq[-1] dq -1 if c[0] == "insert":
            dq.appendleft(c[1])
        elif c[0] == "delete":
            if c[1] in dq:
                dq.remove(c[1]) c[0] == "insert" c[0] c 0 "insert" dq.appendleft(c[1]) dq.appendleft dq appendleft c[1] c 1 elif c[0] == "delete":
            if c[1] in dq:
                dq.remove(c[1]) c[0] == "delete" c[0] c 0 "delete" if c[1] in dq:
                dq.remove(c[1]) c[1] in dq c[1] c 1 dq dq.remove(c[1]) dq.remove dq remove c[1] c 1 print(*dq) print *dq dq dq = deque() deque() dq c = readline().split() readline().split() c readline = sys.stdin.readline sys.stdin.readline readline
import sys
from collections import deque
readline = sys.stdin.readline
dq = deque()
for _ in range(int(input())):
    c = readline().split()
    if c[0] == "deleteFirst":
        del dq[0]
    elif c[0] == "deleteLast":
        del dq[-1]
    else:
        if c[0] == "insert":
            dq.appendleft(c[1])
        elif c[0] == "delete":
            if c[1] in dq:
                dq.remove(c[1])
print(*dq)

