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

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

for i in range(data_cnt):
    line = input().rstrip()
    if line.find(" ") > 0:
        in_command, in_str = line.split(" ")
    else:
        in_command = line
    
    if in_command == "insert":
        output_str.appendleft(in_str)
    elif in_command == "delete":
        if output_str.count(in_str) > 0:
            output_str.remove(in_str)
    elif in_command == "deleteFirst":
        output_str.popleft()
    elif in_command == "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):
    line = input().rstrip()
    if line.find(" ") > 0:
        in_command, in_str = line.split(" ")
    else:
        in_command = line
    
    if in_command == "insert":
        output_str.appendleft(in_str)
    elif in_command == "delete":
        if output_str.count(in_str) > 0:
            output_str.remove(in_str)
    elif in_command == "deleteFirst":
        output_str.popleft()
    elif in_command == "deleteLast": 
        output_str.pop() i range(data_cnt) range data_cnt line = input().rstrip() line input().rstrip() ().rstrip () input rstrip if line.find(" ") > 0:
        in_command, in_str = line.split(" ")
    else:
        in_command = line
    
     line.find(" ") > 0 line.find(" ") line.find line find " " 0 in_command, in_str = line.split(" ") in_command line.split(" ") line.split line split " " in_str in_command = line in_command line if in_command == "insert":
        output_str.appendleft(in_str)
    elif in_command == "delete":
        if output_str.count(in_str) > 0:
            output_str.remove(in_str)
    elif in_command == "deleteFirst":
        output_str.popleft()
    elif in_command == "deleteLast": 
        output_str.pop() in_command == "insert" in_command "insert" output_str.appendleft(in_str) output_str.appendleft output_str appendleft in_str elif in_command == "delete":
        if output_str.count(in_str) > 0:
            output_str.remove(in_str)
     in_command == "delete" in_command "delete" if output_str.count(in_str) > 0:
            output_str.remove(in_str)
     output_str.count(in_str) > 0 output_str.count(in_str) output_str.count output_str count in_str 0 output_str.remove(in_str) output_str.remove output_str remove in_str elif in_command == "deleteFirst":
        output_str.popleft()
     in_command == "deleteFirst" in_command "deleteFirst" output_str.popleft() output_str.popleft output_str popleft elif in_command == "deleteLast": 
        output_str.pop() in_command == "deleteLast" in_command "deleteLast" output_str.pop() output_str.pop output_str pop print(" ".join(output_str)) print " ".join(output_str) " ".join " " join output_str in_command, in_str = line.split(" ") line.split(" ") in_command line = input().rstrip() input().rstrip() line output_str = deque() deque() output_str data_cnt =  int(input()) int(input()) data_cnt in_command = line line in_command in_str = line.split(" ") line.split(" ") in_str
# coding: utf-8
import sys
from collections import deque

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

for i in range(data_cnt):
    line = input().rstrip()
    if line.find(" ") > 0:
        in_command, in_str = line.split(" ")
    else:
        in_command = line
    
    if in_command == "insert":
        output_str.appendleft(in_str)
    elif in_command == "delete":
        if output_str.count(in_str) > 0:
            output_str.remove(in_str)
    elif in_command == "deleteFirst":
        output_str.popleft()
    elif in_command == "deleteLast": 
        output_str.pop()

print(" ".join(output_str))