from collections import deque
d = deque()
n = int(input())
for i in range(n):
    s = input()
    if s == "deleteFirst":
        d.popleft()
    elif s == "deleteLast":
        d.pop()
    elif s[:6] == "insert":
        d.appendleft(int(s[7:]))
    else:
        delkey = int(s[7:])
        if delkey in d:
            d.remove(delkey)

print(" ".join(map(str,d))) from collections import deque d = deque() d deque() deque n = int(input()) n int(input()) int input() input for i in range(n):
    s = input()
    if s == "deleteFirst":
        d.popleft()
    elif s == "deleteLast":
        d.pop()
    elif s[:6] == "insert":
        d.appendleft(int(s[7:]))
    else:
        delkey = int(s[7:])
        if delkey in d:
            d.remove(delkey) i range(n) range n s = input() s input() input if s == "deleteFirst":
        d.popleft()
    elif s == "deleteLast":
        d.pop()
    elif s[:6] == "insert":
        d.appendleft(int(s[7:]))
    else:
        delkey = int(s[7:])
        if delkey in d:
            d.remove(delkey) s == "deleteFirst" s "deleteFirst" d.popleft() d.popleft d popleft elif s == "deleteLast":
        d.pop()
     s == "deleteLast" s "deleteLast" d.pop() d.pop d pop elif s[:6] == "insert":
        d.appendleft(int(s[7:]))
     s[:6] == "insert" s[:6] s :6 6 "insert" d.appendleft(int(s[7:])) d.appendleft d appendleft int(s[7:]) int s[7:] s 7: 7 delkey = int(s[7:]) delkey int(s[7:]) int s[7:] s 7: 7 if delkey in d:
            d.remove(delkey) delkey in d delkey d d.remove(delkey) d.remove d remove delkey print(" ".join(map(str,d))) print " ".join(map(str,d)) " ".join " " join map(str,d) map str d d = deque() deque() d s = input() input() s delkey = int(s[7:]) int(s[7:]) delkey n = int(input()) int(input()) n
from collections import deque
d = deque()
n = int(input())
for i in range(n):
    s = input()
    if s == "deleteFirst":
        d.popleft()
    elif s == "deleteLast":
        d.pop()
    elif s[:6] == "insert":
        d.appendleft(int(s[7:]))
    else:
        delkey = int(s[7:])
        if delkey in d:
            d.remove(delkey)

print(" ".join(map(str,d)))
