from collections import deque

que = deque([])
n = int(input())
for i in range(0, 	n):
	a = input()
	if a == 'deleteFirst':
		que.popleft()
#		print(a)
#		print(que)
	elif a == 'deleteLast':
		que.pop()
#		print(a)
#		print(que)
	else:
		a, b = a.split()
		b = int(b)
		if a == 'insert':
			que.appendleft(b)
#			print('{0} {1}'.format(a,b))
#			print(que)
		elif a == 'delete':
			if que.count(b) != 0:
				que.remove(b)
#			print('{0} {1}'.format(a, b))

print(*que)

#while not len(que) == 0:
#	if len(que) == 1:
#		print(que.pop())
#	else:
#		print(que.pop(), end=' ')
 from collections import deque que = deque([]) que deque([]) deque [] n = int(input()) n int(input()) int input() input for i in range(0, 	n):
	a = input()
	if a == 'deleteFirst':
		que.popleft()
#		print(a)
#		print(que)
	elif a == 'deleteLast':
		que.pop()
#		print(a)
#		print(que)
	else:
		a, b = a.split()
		b = int(b)
		if a == 'insert':
			que.appendleft(b)
#			print('{0} {1}'.format(a,b))
#			print(que)
		elif a == 'delete':
			if que.count(b) != 0:
				que.remove(b)
#			print('{0} {1}'.format(a, b)) i range(0, 	n) range 0 n a = input() a input() input if a == 'deleteFirst':
		que.popleft()
#		print(a)
#		print(que)
	elif a == 'deleteLast':
		que.pop()
#		print(a)
#		print(que)
	else:
		a, b = a.split()
		b = int(b)
		if a == 'insert':
			que.appendleft(b)
#			print('{0} {1}'.format(a,b))
#			print(que)
		elif a == 'delete':
			if que.count(b) != 0:
				que.remove(b)
#			print('{0} {1}'.format(a, b)) a == 'deleteFirst' a 'deleteFirst' que.popleft() que.popleft que popleft elif a == 'deleteLast':
		que.pop()
#		print(a)
#		print(que)
	 a == 'deleteLast' a 'deleteLast' que.pop() que.pop que pop a, b = a.split() a a.split() a.split a split b b = int(b) b int(b) int b if a == 'insert':
			que.appendleft(b)
#			print('{0} {1}'.format(a,b))
#			print(que)
		elif a == 'delete':
			if que.count(b) != 0:
				que.remove(b)
#			print('{0} {1}'.format(a, b)) a == 'insert' a 'insert' que.appendleft(b) que.appendleft que appendleft b elif a == 'delete':
			if que.count(b) != 0:
				que.remove(b)
#			print('{0} {1}'.format(a, b)) a == 'delete' a 'delete' if que.count(b) != 0:
				que.remove(b)
#			print('{0} {1}'.format(a, b)) que.count(b) != 0 que.count(b) que.count que count b 0 que.remove(b) que.remove que remove b print(*que) print *que que a = input() input() a a, b = a.split() a.split() a que = deque([]) deque([]) que b = a.split() a.split() b b = int(b) int(b) b n = int(input()) int(input()) n
from collections import deque

que = deque([])
n = int(input())
for i in range(0, 	n):
	a = input()
	if a == 'deleteFirst':
		que.popleft()
#		print(a)
#		print(que)
	elif a == 'deleteLast':
		que.pop()
#		print(a)
#		print(que)
	else:
		a, b = a.split()
		b = int(b)
		if a == 'insert':
			que.appendleft(b)
#			print('{0} {1}'.format(a,b))
#			print(que)
		elif a == 'delete':
			if que.count(b) != 0:
				que.remove(b)
#			print('{0} {1}'.format(a, b))

print(*que)

#while not len(que) == 0:
#	if len(que) == 1:
#		print(que.pop())
#	else:
#		print(que.pop(), end=' ')

