from collections import deque
a = deque([])
for i in range(int(input())):
    c = input().split()
    if c[0] == "insert":
        a.appendleft(c[1])
    elif c[0] == "delete":
        try:
            a.remove(c[1])
        except ValueError:
            pass
    elif c[0] == "deleteFirst":
        a.popleft()
    else:
        a.pop()
for i,e in enumerate(a):
    if i == len(a) - 1:
        print(e)
    else:
        print(e, end=" ")
 from collections import deque a = deque([]) a deque([]) deque [] for i in range(int(input())):
    c = input().split()
    if c[0] == "insert":
        a.appendleft(c[1])
    elif c[0] == "delete":
        try:
            a.remove(c[1])
        except ValueError:
            pass
    elif c[0] == "deleteFirst":
        a.popleft()
    else:
        a.pop() i range(int(input())) range int(input()) int input() input c = input().split() c input().split() ().split () input split if c[0] == "insert":
        a.appendleft(c[1])
    elif c[0] == "delete":
        try:
            a.remove(c[1])
        except ValueError:
            pass
    elif c[0] == "deleteFirst":
        a.popleft()
    else:
        a.pop() c[0] == "insert" c[0] c 0 "insert" a.appendleft(c[1]) a.appendleft a appendleft c[1] c 1 elif c[0] == "delete":
        try:
            a.remove(c[1])
        except ValueError:
            pass
     c[0] == "delete" c[0] c 0 "delete" try:
            a.remove(c[1])
        except ValueError:
            pass
     except ValueError:
            pass
     a.remove(c[1]) a.remove a remove c[1] c 1 elif c[0] == "deleteFirst":
        a.popleft()
     c[0] == "deleteFirst" c[0] c 0 "deleteFirst" a.popleft() a.popleft a popleft a.pop() a.pop a pop for i,e in enumerate(a):
    if i == len(a) - 1:
        print(e)
    else:
        print(e, end=" ") i e enumerate(a) enumerate a if i == len(a) - 1:
        print(e)
    else:
        print(e, end=" ") i == len(a) - 1 i len(a) - 1 len(a) len a 1 print(e) print e print(e, end=" ") print e end=" " end " " a = deque([]) deque([]) a c = input().split() input().split() c
from collections import deque
a = deque([])
for i in range(int(input())):
    c = input().split()
    if c[0] == "insert":
        a.appendleft(c[1])
    elif c[0] == "delete":
        try:
            a.remove(c[1])
        except ValueError:
            pass
    elif c[0] == "deleteFirst":
        a.popleft()
    else:
        a.pop()
for i,e in enumerate(a):
    if i == len(a) - 1:
        print(e)
    else:
        print(e, end=" ")

