from collections import deque
n = int(input())
dlist = deque()
for i in range(n):
    code = input().split()
    if code[0] == "insert":
        dlist.insert(0,code[1])
    if code[0] == "delete":
        try:
            dlist.remove(code[1])
        except:
            continue
    if code[0] == "deleteFirst":
        dlist.popleft()
    if code[0] == "deleteLast":
        dlist.pop()
print(*dlist,sep=" ") from collections import deque n = int(input()) n int(input()) int input() input dlist = deque() dlist deque() deque for i in range(n):
    code = input().split()
    if code[0] == "insert":
        dlist.insert(0,code[1])
    if code[0] == "delete":
        try:
            dlist.remove(code[1])
        except:
            continue
    if code[0] == "deleteFirst":
        dlist.popleft()
    if code[0] == "deleteLast":
        dlist.pop() i range(n) range n code = input().split() code input().split() ().split () input split if code[0] == "insert":
        dlist.insert(0,code[1])
     code[0] == "insert" code[0] code 0 "insert" dlist.insert(0,code[1]) dlist.insert dlist insert 0 code[1] code 1 if code[0] == "delete":
        try:
            dlist.remove(code[1])
        except:
            continue
     code[0] == "delete" code[0] code 0 "delete" try:
            dlist.remove(code[1])
        except:
            continue
     except:
            continue
     continue dlist.remove(code[1]) dlist.remove dlist remove code[1] code 1 if code[0] == "deleteFirst":
        dlist.popleft()
     code[0] == "deleteFirst" code[0] code 0 "deleteFirst" dlist.popleft() dlist.popleft dlist popleft if code[0] == "deleteLast":
        dlist.pop() code[0] == "deleteLast" code[0] code 0 "deleteLast" dlist.pop() dlist.pop dlist pop print(*dlist,sep=" ") print *dlist dlist sep=" " sep " " code = input().split() input().split() code dlist = deque() deque() dlist n = int(input()) int(input()) n
from collections import deque
n = int(input())
dlist = deque()
for i in range(n):
    code = input().split()
    if code[0] == "insert":
        dlist.insert(0,code[1])
    if code[0] == "delete":
        try:
            dlist.remove(code[1])
        except:
            continue
    if code[0] == "deleteFirst":
        dlist.popleft()
    if code[0] == "deleteLast":
        dlist.pop()
print(*dlist,sep=" ")