import sys
from collections import deque 

def input():
	return sys.stdin.readline().rstrip()

input()
a = deque()

while True:
	op = input().split()
	if not op:
		break
	if op[0] == 'insert':
		a.appendleft(int(op[1]))
	elif op[0] == 'delete':
		try:
			a.remove(int(op[1]))
		except:
			pass
	elif op[0] == 'deleteFirst':
		a.popleft()
	elif op[0] == 'deleteLast':
		a.pop()

while True:
	x = a.popleft()
	print(x, end="")
	if len(a)>0:
		print(" ", end="")
	else:
		print("")
		break
 import sys sys from collections import deque def input():
	return sys.stdin.readline().rstrip() input return sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip input() input a = deque() a deque() deque while True:
	op = input().split()
	if not op:
		break
	if op[0] == 'insert':
		a.appendleft(int(op[1]))
	elif op[0] == 'delete':
		try:
			a.remove(int(op[1]))
		except:
			pass
	elif op[0] == 'deleteFirst':
		a.popleft()
	elif op[0] == 'deleteLast':
		a.pop() True op = input().split() op input().split() ().split () input split if not op:
		break
	 not op op break if op[0] == 'insert':
		a.appendleft(int(op[1]))
	elif op[0] == 'delete':
		try:
			a.remove(int(op[1]))
		except:
			pass
	elif op[0] == 'deleteFirst':
		a.popleft()
	elif op[0] == 'deleteLast':
		a.pop() op[0] == 'insert' op[0] op 0 'insert' a.appendleft(int(op[1])) a.appendleft a appendleft int(op[1]) int op[1] op 1 elif op[0] == 'delete':
		try:
			a.remove(int(op[1]))
		except:
			pass
	 op[0] == 'delete' op[0] op 0 'delete' try:
			a.remove(int(op[1]))
		except:
			pass
	 except:
			pass
	 a.remove(int(op[1])) a.remove a remove int(op[1]) int op[1] op 1 elif op[0] == 'deleteFirst':
		a.popleft()
	 op[0] == 'deleteFirst' op[0] op 0 'deleteFirst' a.popleft() a.popleft a popleft elif op[0] == 'deleteLast':
		a.pop() op[0] == 'deleteLast' op[0] op 0 'deleteLast' a.pop() a.pop a pop while True:
	x = a.popleft()
	print(x, end="")
	if len(a)>0:
		print(" ", end="")
	else:
		print("")
		break True x = a.popleft() x a.popleft() a.popleft a popleft print(x, end="") print x end="" end "" if len(a)>0:
		print(" ", end="")
	else:
		print("")
		break len(a)>0 len(a) len a 0 print(" ", end="") print " " end="" end "" print("") print "" break a = deque() deque() a x = a.popleft() a.popleft() x op = input().split() input().split() op def input():
	return sys.stdin.readline().rstrip() def input():
	return sys.stdin.readline().rstrip() input
import sys
from collections import deque 

def input():
	return sys.stdin.readline().rstrip()

input()
a = deque()

while True:
	op = input().split()
	if not op:
		break
	if op[0] == 'insert':
		a.appendleft(int(op[1]))
	elif op[0] == 'delete':
		try:
			a.remove(int(op[1]))
		except:
			pass
	elif op[0] == 'deleteFirst':
		a.popleft()
	elif op[0] == 'deleteLast':
		a.pop()

while True:
	x = a.popleft()
	print(x, end="")
	if len(a)>0:
		print(" ", end="")
	else:
		print("")
		break

