from collections import deque

n = int(input())

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

n = int(input())

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