import sys
from collections import deque

n = int( sys.stdin.readline( ) )
que = deque( )
lines = sys.stdin.readlines()
for line in lines:
	op = line.rstrip().split( " " )
	if "insert" == op[0]:
		que.appendleft( op[1] )
	elif "delete" == op[0]:
		if op[1] in que:
			que.remove( op[1] )
	elif "deleteFirst" == op[0] :
		que.popleft( )
	elif "deleteLast" == op[0]:
		que.pop( )


print( " ".join( que ) ) import sys sys from collections import deque n = int( sys.stdin.readline( ) ) n int( sys.stdin.readline( ) ) int sys.stdin.readline( ) sys.stdin.readline sys.stdin sys stdin readline que = deque( ) que deque( ) deque lines = sys.stdin.readlines() lines sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines for line in lines:
	op = line.rstrip().split( " " )
	if "insert" == op[0]:
		que.appendleft( op[1] )
	elif "delete" == op[0]:
		if op[1] in que:
			que.remove( op[1] )
	elif "deleteFirst" == op[0] :
		que.popleft( )
	elif "deleteLast" == op[0]:
		que.pop( ) line lines op = line.rstrip().split( " " ) op line.rstrip().split( " " ) line.rstrip().split line.rstrip() line.rstrip line rstrip split " " if "insert" == op[0]:
		que.appendleft( op[1] )
	elif "delete" == op[0]:
		if op[1] in que:
			que.remove( op[1] )
	elif "deleteFirst" == op[0] :
		que.popleft( )
	elif "deleteLast" == op[0]:
		que.pop( ) "insert" == op[0] "insert" op[0] op 0 que.appendleft( op[1] ) que.appendleft que appendleft op[1] op 1 elif "delete" == op[0]:
		if op[1] in que:
			que.remove( op[1] )
	 "delete" == op[0] "delete" op[0] op 0 if op[1] in que:
			que.remove( op[1] )
	 op[1] in que op[1] op 1 que que.remove( op[1] ) que.remove que remove op[1] op 1 elif "deleteFirst" == op[0] :
		que.popleft( )
	 "deleteFirst" == op[0] "deleteFirst" op[0] op 0 que.popleft( ) que.popleft que popleft elif "deleteLast" == op[0]:
		que.pop( ) "deleteLast" == op[0] "deleteLast" op[0] op 0 que.pop( ) que.pop que pop print( " ".join( que ) ) print " ".join( que ) " ".join " " join que op = line.rstrip().split( " " ) line.rstrip().split( " " ) op n = int( sys.stdin.readline( ) ) int( sys.stdin.readline( ) ) n que = deque( ) deque( ) que lines = sys.stdin.readlines() sys.stdin.readlines() lines
import sys
from collections import deque

n = int( sys.stdin.readline( ) )
que = deque( )
lines = sys.stdin.readlines()
for line in lines:
	op = line.rstrip().split( " " )
	if "insert" == op[0]:
		que.appendleft( op[1] )
	elif "delete" == op[0]:
		if op[1] in que:
			que.remove( op[1] )
	elif "deleteFirst" == op[0] :
		que.popleft( )
	elif "deleteLast" == op[0]:
		que.pop( )


print( " ".join( que ) )