import collections 
List=collections.deque()
n=int(input())
for i in range(n):
	command=input().split()
	if command[0] == 'insert':
		List.appendleft(command[1])		
	elif command[0] == 'delete':
		try:List.remove(command[1])
		except:pass
	elif command[0] == 'deleteFirst':
		List.popleft()	
	elif command[0] == 'deleteLast':
		List.pop()
		
print(*List)
 import collections collections List=collections.deque() List collections.deque() collections.deque collections deque n=int(input()) n int(input()) int input() input for i in range(n):
	command=input().split()
	if command[0] == 'insert':
		List.appendleft(command[1])		
	elif command[0] == 'delete':
		try:List.remove(command[1])
		except:pass
	elif command[0] == 'deleteFirst':
		List.popleft()	
	elif command[0] == 'deleteLast':
		List.pop()
		 i range(n) range n command=input().split() command input().split() ().split () input split if command[0] == 'insert':
		List.appendleft(command[1])		
	elif command[0] == 'delete':
		try:List.remove(command[1])
		except:pass
	elif command[0] == 'deleteFirst':
		List.popleft()	
	elif command[0] == 'deleteLast':
		List.pop()
		 command[0] == 'insert' command[0] command 0 'insert' List.appendleft(command[1]) List.appendleft List appendleft command[1] command 1 elif command[0] == 'delete':
		try:List.remove(command[1])
		except:pass
	 command[0] == 'delete' command[0] command 0 'delete' try:List.remove(command[1])
		except:pass
	 except:pass
	 elif command[0] == 'deleteFirst':
		List.popleft()	
	 command[0] == 'deleteFirst' command[0] command 0 'deleteFirst' List.popleft() List.popleft List popleft elif command[0] == 'deleteLast':
		List.pop()
		 command[0] == 'deleteLast' command[0] command 0 'deleteLast' List.pop() List.pop List pop print(*List) print *List List command=input().split() input().split() command List=collections.deque() collections.deque() List n=int(input()) int(input()) n
import collections 
List=collections.deque()
n=int(input())
for i in range(n):
	command=input().split()
	if command[0] == 'insert':
		List.appendleft(command[1])		
	elif command[0] == 'delete':
		try:List.remove(command[1])
		except:pass
	elif command[0] == 'deleteFirst':
		List.popleft()	
	elif command[0] == 'deleteLast':
		List.pop()
		
print(*List)

