n = int(input())
import collections
d = collections.deque([])
for _ in range(n):
    s = input().split()
    if s[0] == "deleteFirst":
        d.popleft()
    elif s[0] == "deleteLast":
        d.pop()
    elif s[0] == "insert":
        d.appendleft(s[1])
    else:
        try:
            d.remove(s[1])
        except:
            pass
print(" ".join(d))
 n = int(input()) n int(input()) int input() input import collections collections d = collections.deque([]) d collections.deque([]) collections.deque collections deque [] for _ in range(n):
    s = input().split()
    if s[0] == "deleteFirst":
        d.popleft()
    elif s[0] == "deleteLast":
        d.pop()
    elif s[0] == "insert":
        d.appendleft(s[1])
    else:
        try:
            d.remove(s[1])
        except:
            pass _ range(n) range n s = input().split() s input().split() ().split () input split if s[0] == "deleteFirst":
        d.popleft()
    elif s[0] == "deleteLast":
        d.pop()
    elif s[0] == "insert":
        d.appendleft(s[1])
    else:
        try:
            d.remove(s[1])
        except:
            pass s[0] == "deleteFirst" s[0] s 0 "deleteFirst" d.popleft() d.popleft d popleft elif s[0] == "deleteLast":
        d.pop()
     s[0] == "deleteLast" s[0] s 0 "deleteLast" d.pop() d.pop d pop elif s[0] == "insert":
        d.appendleft(s[1])
     s[0] == "insert" s[0] s 0 "insert" d.appendleft(s[1]) d.appendleft d appendleft s[1] s 1 try:
            d.remove(s[1])
        except:
            pass except:
            pass d.remove(s[1]) d.remove d remove s[1] s 1 print(" ".join(d)) print " ".join(d) " ".join " " join d s = input().split() input().split() s n = int(input()) int(input()) n d = collections.deque([]) collections.deque([]) d
n = int(input())
import collections
d = collections.deque([])
for _ in range(n):
    s = input().split()
    if s[0] == "deleteFirst":
        d.popleft()
    elif s[0] == "deleteLast":
        d.pop()
    elif s[0] == "insert":
        d.appendleft(s[1])
    else:
        try:
            d.remove(s[1])
        except:
            pass
print(" ".join(d))

