from collections import deque

dq = deque()
n = int(input())
for _ in range(n):
    cmd = input().split()
    if cmd[0] == "insert":
        dq.appendleft(cmd[1])
    elif cmd[0] == "delete":
        try:
            dq.remove(cmd[1])
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        dq.popleft()
    else:
        dq.pop()
print(*dq) from collections import deque dq = deque() dq deque() deque n = int(input()) n int(input()) int input() input for _ in range(n):
    cmd = input().split()
    if cmd[0] == "insert":
        dq.appendleft(cmd[1])
    elif cmd[0] == "delete":
        try:
            dq.remove(cmd[1])
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        dq.popleft()
    else:
        dq.pop() _ range(n) range n cmd = input().split() cmd input().split() ().split () input split if cmd[0] == "insert":
        dq.appendleft(cmd[1])
    elif cmd[0] == "delete":
        try:
            dq.remove(cmd[1])
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        dq.popleft()
    else:
        dq.pop() cmd[0] == "insert" cmd[0] cmd 0 "insert" dq.appendleft(cmd[1]) dq.appendleft dq appendleft cmd[1] cmd 1 elif cmd[0] == "delete":
        try:
            dq.remove(cmd[1])
        except ValueError:
            pass
     cmd[0] == "delete" cmd[0] cmd 0 "delete" try:
            dq.remove(cmd[1])
        except ValueError:
            pass
     except ValueError:
            pass
     dq.remove(cmd[1]) dq.remove dq remove cmd[1] cmd 1 elif cmd[0] == "deleteFirst":
        dq.popleft()
     cmd[0] == "deleteFirst" cmd[0] cmd 0 "deleteFirst" dq.popleft() dq.popleft dq popleft dq.pop() dq.pop dq pop print(*dq) print *dq dq n = int(input()) int(input()) n cmd = input().split() input().split() cmd dq = deque() deque() dq
from collections import deque

dq = deque()
n = int(input())
for _ in range(n):
    cmd = input().split()
    if cmd[0] == "insert":
        dq.appendleft(cmd[1])
    elif cmd[0] == "delete":
        try:
            dq.remove(cmd[1])
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        dq.popleft()
    else:
        dq.pop()
print(*dq)