from collections import deque
from sys import stdin

n = int(input())

q = deque()

for _ in range(n):
	cmd = stdin.readline().strip().split()
	if cmd[0] == "insert":
		q.appendleft(cmd[1])
	elif cmd[0] == "deleteFirst":
		q.popleft()
	elif cmd[0] == "deleteLast":
		q.pop()
	elif cmd[0] == "delete":
		try:
			q.remove(cmd[1])
		except:
			pass

print(*q)
 from collections import deque from sys import stdin n = int(input()) n int(input()) int input() input q = deque() q deque() deque for _ in range(n):
	cmd = stdin.readline().strip().split()
	if cmd[0] == "insert":
		q.appendleft(cmd[1])
	elif cmd[0] == "deleteFirst":
		q.popleft()
	elif cmd[0] == "deleteLast":
		q.pop()
	elif cmd[0] == "delete":
		try:
			q.remove(cmd[1])
		except:
			pass _ range(n) range n cmd = stdin.readline().strip().split() cmd stdin.readline().strip().split() stdin.readline().strip().split stdin.readline().strip() stdin.readline().strip stdin.readline() stdin.readline stdin readline strip split if cmd[0] == "insert":
		q.appendleft(cmd[1])
	elif cmd[0] == "deleteFirst":
		q.popleft()
	elif cmd[0] == "deleteLast":
		q.pop()
	elif cmd[0] == "delete":
		try:
			q.remove(cmd[1])
		except:
			pass cmd[0] == "insert" cmd[0] cmd 0 "insert" q.appendleft(cmd[1]) q.appendleft q appendleft cmd[1] cmd 1 elif cmd[0] == "deleteFirst":
		q.popleft()
	 cmd[0] == "deleteFirst" cmd[0] cmd 0 "deleteFirst" q.popleft() q.popleft q popleft elif cmd[0] == "deleteLast":
		q.pop()
	 cmd[0] == "deleteLast" cmd[0] cmd 0 "deleteLast" q.pop() q.pop q pop elif cmd[0] == "delete":
		try:
			q.remove(cmd[1])
		except:
			pass cmd[0] == "delete" cmd[0] cmd 0 "delete" try:
			q.remove(cmd[1])
		except:
			pass except:
			pass q.remove(cmd[1]) q.remove q remove cmd[1] cmd 1 print(*q) print *q q q = deque() deque() q n = int(input()) int(input()) n cmd = stdin.readline().strip().split() stdin.readline().strip().split() cmd
from collections import deque
from sys import stdin

n = int(input())

q = deque()

for _ in range(n):
	cmd = stdin.readline().strip().split()
	if cmd[0] == "insert":
		q.appendleft(cmd[1])
	elif cmd[0] == "deleteFirst":
		q.popleft()
	elif cmd[0] == "deleteLast":
		q.pop()
	elif cmd[0] == "delete":
		try:
			q.remove(cmd[1])
		except:
			pass

print(*q)

