# coding: utf-8
import sys
from collections import deque

output_str = deque()
data_cnt =  int(input())  

for i in range(data_cnt):
    in_command = input().rstrip().split(" ")
    
    if in_command[0] == "insert":
        output_str.appendleft(in_command[1])
    elif in_command[0] == "delete":
        if output_str.count(in_command[1]) > 0:
            output_str.remove(in_command[1])
    elif in_command[0] == "deleteFirst":
        output_str.popleft()
    elif in_command[0] == "deleteLast": 
        output_str.pop()

print(" ".join(output_str)) import sys sys from collections import deque output_str = deque() output_str deque() deque data_cnt =  int(input()) data_cnt int(input()) int input() input for i in range(data_cnt):
    in_command = input().rstrip().split(" ")
    
    if in_command[0] == "insert":
        output_str.appendleft(in_command[1])
    elif in_command[0] == "delete":
        if output_str.count(in_command[1]) > 0:
            output_str.remove(in_command[1])
    elif in_command[0] == "deleteFirst":
        output_str.popleft()
    elif in_command[0] == "deleteLast": 
        output_str.pop() i range(data_cnt) range data_cnt in_command = input().rstrip().split(" ") in_command input().rstrip().split(" ") ().rstrip().split ().rstrip() ().rstrip () input rstrip split " " if in_command[0] == "insert":
        output_str.appendleft(in_command[1])
    elif in_command[0] == "delete":
        if output_str.count(in_command[1]) > 0:
            output_str.remove(in_command[1])
    elif in_command[0] == "deleteFirst":
        output_str.popleft()
    elif in_command[0] == "deleteLast": 
        output_str.pop() in_command[0] == "insert" in_command[0] in_command 0 "insert" output_str.appendleft(in_command[1]) output_str.appendleft output_str appendleft in_command[1] in_command 1 elif in_command[0] == "delete":
        if output_str.count(in_command[1]) > 0:
            output_str.remove(in_command[1])
     in_command[0] == "delete" in_command[0] in_command 0 "delete" if output_str.count(in_command[1]) > 0:
            output_str.remove(in_command[1])
     output_str.count(in_command[1]) > 0 output_str.count(in_command[1]) output_str.count output_str count in_command[1] in_command 1 0 output_str.remove(in_command[1]) output_str.remove output_str remove in_command[1] in_command 1 elif in_command[0] == "deleteFirst":
        output_str.popleft()
     in_command[0] == "deleteFirst" in_command[0] in_command 0 "deleteFirst" output_str.popleft() output_str.popleft output_str popleft elif in_command[0] == "deleteLast": 
        output_str.pop() in_command[0] == "deleteLast" in_command[0] in_command 0 "deleteLast" output_str.pop() output_str.pop output_str pop print(" ".join(output_str)) print " ".join(output_str) " ".join " " join output_str output_str = deque() deque() output_str in_command = input().rstrip().split(" ") input().rstrip().split(" ") in_command data_cnt =  int(input()) int(input()) data_cnt
# coding: utf-8
import sys
from collections import deque

output_str = deque()
data_cnt =  int(input())  

for i in range(data_cnt):
    in_command = input().rstrip().split(" ")
    
    if in_command[0] == "insert":
        output_str.appendleft(in_command[1])
    elif in_command[0] == "delete":
        if output_str.count(in_command[1]) > 0:
            output_str.remove(in_command[1])
    elif in_command[0] == "deleteFirst":
        output_str.popleft()
    elif in_command[0] == "deleteLast": 
        output_str.pop()

print(" ".join(output_str))