from collections import deque

n = int(input())
data = deque()

for i in range(n):
	command = input().split()
	if len(command) == 2:
		command,x = command
	else:
		command = command[0]
	if command == 'insert':
		data.appendleft(x)
	elif command == 'delete':
		if x in data:
			data.remove(x)
	elif command == 'deleteFirst':
		data.popleft()
	elif command == 'deleteLast':
		data.pop()

print(*data) from collections import deque n = int(input()) n int(input()) int input() input data = deque() data deque() deque for i in range(n):
	command = input().split()
	if len(command) == 2:
		command,x = command
	else:
		command = command[0]
	if command == 'insert':
		data.appendleft(x)
	elif command == 'delete':
		if x in data:
			data.remove(x)
	elif command == 'deleteFirst':
		data.popleft()
	elif command == 'deleteLast':
		data.pop() i range(n) range n command = input().split() command input().split() ().split () input split if len(command) == 2:
		command,x = command
	else:
		command = command[0]
	 len(command) == 2 len(command) len command 2 command,x = command command command x command = command[0] command command[0] command 0 if command == 'insert':
		data.appendleft(x)
	elif command == 'delete':
		if x in data:
			data.remove(x)
	elif command == 'deleteFirst':
		data.popleft()
	elif command == 'deleteLast':
		data.pop() command == 'insert' command 'insert' data.appendleft(x) data.appendleft data appendleft x elif command == 'delete':
		if x in data:
			data.remove(x)
	 command == 'delete' command 'delete' if x in data:
			data.remove(x)
	 x in data x data data.remove(x) data.remove data remove x elif command == 'deleteFirst':
		data.popleft()
	 command == 'deleteFirst' command 'deleteFirst' data.popleft() data.popleft data popleft elif command == 'deleteLast':
		data.pop() command == 'deleteLast' command 'deleteLast' data.pop() data.pop data pop print(*data) print *data data command,x = command command command n = int(input()) int(input()) n command = input().split() input().split() command command = command[0] command[0] command data = deque() deque() data x = command command x
from collections import deque

n = int(input())
data = deque()

for i in range(n):
	command = input().split()
	if len(command) == 2:
		command,x = command
	else:
		command = command[0]
	if command == 'insert':
		data.appendleft(x)
	elif command == 'delete':
		if x in data:
			data.remove(x)
	elif command == 'deleteFirst':
		data.popleft()
	elif command == 'deleteLast':
		data.pop()

print(*data)