from collections import deque
n = int(input())
a = deque()
for i in range(n):
    s = input().split(" ")
    if s[0] == "insert":
        a.appendleft(int(s[1]))
    elif s[0] == "delete":
        if int(s[1]) in a:
            a.remove(int(s[1]))
    elif s[0] == "deleteLast":
        a.pop()
    elif s[0] == "deleteFirst":
        a.popleft()
b = list(a)
for i in range(len(b)):
    if i == len(b)-1:
        print(b[i])
    else:
        print(b[i],end=" ") from collections import deque n = int(input()) n int(input()) int input() input a = deque() a deque() deque for i in range(n):
    s = input().split(" ")
    if s[0] == "insert":
        a.appendleft(int(s[1]))
    elif s[0] == "delete":
        if int(s[1]) in a:
            a.remove(int(s[1]))
    elif s[0] == "deleteLast":
        a.pop()
    elif s[0] == "deleteFirst":
        a.popleft() i range(n) range n s = input().split(" ") s input().split(" ") ().split () input split " " if s[0] == "insert":
        a.appendleft(int(s[1]))
    elif s[0] == "delete":
        if int(s[1]) in a:
            a.remove(int(s[1]))
    elif s[0] == "deleteLast":
        a.pop()
    elif s[0] == "deleteFirst":
        a.popleft() s[0] == "insert" s[0] s 0 "insert" a.appendleft(int(s[1])) a.appendleft a appendleft int(s[1]) int s[1] s 1 elif s[0] == "delete":
        if int(s[1]) in a:
            a.remove(int(s[1]))
     s[0] == "delete" s[0] s 0 "delete" if int(s[1]) in a:
            a.remove(int(s[1]))
     int(s[1]) in a int(s[1]) int s[1] s 1 a a.remove(int(s[1])) a.remove a remove int(s[1]) int s[1] s 1 elif s[0] == "deleteLast":
        a.pop()
     s[0] == "deleteLast" s[0] s 0 "deleteLast" a.pop() a.pop a pop elif s[0] == "deleteFirst":
        a.popleft() s[0] == "deleteFirst" s[0] s 0 "deleteFirst" a.popleft() a.popleft a popleft b = list(a) b list(a) list a for i in range(len(b)):
    if i == len(b)-1:
        print(b[i])
    else:
        print(b[i],end=" ") i range(len(b)) range len(b) len b if i == len(b)-1:
        print(b[i])
    else:
        print(b[i],end=" ") i == len(b)-1 i len(b)-1 len(b) len b 1 print(b[i]) print b[i] b i print(b[i],end=" ") print b[i] b i end=" " end " " s = input().split(" ") input().split(" ") s a = deque() deque() a b = list(a) list(a) b n = int(input()) int(input()) n
from collections import deque
n = int(input())
a = deque()
for i in range(n):
    s = input().split(" ")
    if s[0] == "insert":
        a.appendleft(int(s[1]))
    elif s[0] == "delete":
        if int(s[1]) in a:
            a.remove(int(s[1]))
    elif s[0] == "deleteLast":
        a.pop()
    elif s[0] == "deleteFirst":
        a.popleft()
b = list(a)
for i in range(len(b)):
    if i == len(b)-1:
        print(b[i])
    else:
        print(b[i],end=" ")