from collections import deque
import sys
input = sys.stdin.readline

n = int(input())
l = deque()

for _ in range(n):
    op = input().strip().split()
    if op[0] == "insert":
        l.appendleft(op[1])
    elif op[0] == "delete":
        if op[1] in l:
            l.remove(op[1])
    elif op[0] == "deleteFirst":
        l.popleft()
    elif op[0] == "deleteLast":
        l.pop()
print(" ".join(l))
 from collections import deque import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n = int(input()) n int(input()) int input() input l = deque() l deque() deque for _ in range(n):
    op = input().strip().split()
    if op[0] == "insert":
        l.appendleft(op[1])
    elif op[0] == "delete":
        if op[1] in l:
            l.remove(op[1])
    elif op[0] == "deleteFirst":
        l.popleft()
    elif op[0] == "deleteLast":
        l.pop() _ range(n) range n op = input().strip().split() op input().strip().split() ().strip().split ().strip() ().strip () input strip split if op[0] == "insert":
        l.appendleft(op[1])
    elif op[0] == "delete":
        if op[1] in l:
            l.remove(op[1])
    elif op[0] == "deleteFirst":
        l.popleft()
    elif op[0] == "deleteLast":
        l.pop() op[0] == "insert" op[0] op 0 "insert" l.appendleft(op[1]) l.appendleft l appendleft op[1] op 1 elif op[0] == "delete":
        if op[1] in l:
            l.remove(op[1])
     op[0] == "delete" op[0] op 0 "delete" if op[1] in l:
            l.remove(op[1])
     op[1] in l op[1] op 1 l l.remove(op[1]) l.remove l remove op[1] op 1 elif op[0] == "deleteFirst":
        l.popleft()
     op[0] == "deleteFirst" op[0] op 0 "deleteFirst" l.popleft() l.popleft l popleft elif op[0] == "deleteLast":
        l.pop() op[0] == "deleteLast" op[0] op 0 "deleteLast" l.pop() l.pop l pop print(" ".join(l)) print " ".join(l) " ".join " " join l input = sys.stdin.readline sys.stdin.readline input op = input().strip().split() input().strip().split() op n = int(input()) int(input()) n l = deque() deque() l
from collections import deque
import sys
input = sys.stdin.readline

n = int(input())
l = deque()

for _ in range(n):
    op = input().strip().split()
    if op[0] == "insert":
        l.appendleft(op[1])
    elif op[0] == "delete":
        if op[1] in l:
            l.remove(op[1])
    elif op[0] == "deleteFirst":
        l.popleft()
    elif op[0] == "deleteLast":
        l.pop()
print(" ".join(l))

