from collections import deque
import sys

input = sys.stdin.readline

n = int(input())

doubly_linked_list = deque()

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

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

input = sys.stdin.readline

n = int(input())

doubly_linked_list = deque()

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

print(" ".join(doubly_linked_list))
    

