from collections import deque
n = int(input())

Q = deque()
for i in range(n):
    command = input().split()
    if command[0] == "insert":
        Q.appendleft(command[1])
    elif command[0] == "deleteFirst":
        Q.popleft()
    elif command[0] == "deleteLast":
        Q.pop()
    elif command[0] == "delete":
        try:
            Q.remove(command[1])
        except:
            pass
print(" ".join(Q)) from collections import deque n = int(input()) n int(input()) int input() input Q = deque() Q deque() deque for i in range(n):
    command = input().split()
    if command[0] == "insert":
        Q.appendleft(command[1])
    elif command[0] == "deleteFirst":
        Q.popleft()
    elif command[0] == "deleteLast":
        Q.pop()
    elif command[0] == "delete":
        try:
            Q.remove(command[1])
        except:
            pass i range(n) range n command = input().split() command input().split() ().split () input split if command[0] == "insert":
        Q.appendleft(command[1])
    elif command[0] == "deleteFirst":
        Q.popleft()
    elif command[0] == "deleteLast":
        Q.pop()
    elif command[0] == "delete":
        try:
            Q.remove(command[1])
        except:
            pass command[0] == "insert" command[0] command 0 "insert" Q.appendleft(command[1]) Q.appendleft Q appendleft command[1] command 1 elif command[0] == "deleteFirst":
        Q.popleft()
     command[0] == "deleteFirst" command[0] command 0 "deleteFirst" Q.popleft() Q.popleft Q popleft elif command[0] == "deleteLast":
        Q.pop()
     command[0] == "deleteLast" command[0] command 0 "deleteLast" Q.pop() Q.pop Q pop elif command[0] == "delete":
        try:
            Q.remove(command[1])
        except:
            pass command[0] == "delete" command[0] command 0 "delete" try:
            Q.remove(command[1])
        except:
            pass except:
            pass Q.remove(command[1]) Q.remove Q remove command[1] command 1 print(" ".join(Q)) print " ".join(Q) " ".join " " join Q Q = deque() deque() Q n = int(input()) int(input()) n command = input().split() input().split() command
from collections import deque
n = int(input())

Q = deque()
for i in range(n):
    command = input().split()
    if command[0] == "insert":
        Q.appendleft(command[1])
    elif command[0] == "deleteFirst":
        Q.popleft()
    elif command[0] == "deleteLast":
        Q.pop()
    elif command[0] == "delete":
        try:
            Q.remove(command[1])
        except:
            pass
print(" ".join(Q))