from collections import deque

dq=deque()
n=int(input())

for i in range(n):
	com=input().split()
	if com[0]=='insert':
		dq.appendleft(com[1])
	elif com[0]=='deleteFirst':
		dq.popleft()
	elif com[0]=='deleteLast':
		dq.pop()
	else:
		if com[1] in dq:
			dq.remove(com[1])
print(' '.join(dq)) from collections import deque dq=deque() dq deque() deque n=int(input()) n int(input()) int input() input for i in range(n):
	com=input().split()
	if com[0]=='insert':
		dq.appendleft(com[1])
	elif com[0]=='deleteFirst':
		dq.popleft()
	elif com[0]=='deleteLast':
		dq.pop()
	else:
		if com[1] in dq:
			dq.remove(com[1]) i range(n) range n com=input().split() com input().split() ().split () input split if com[0]=='insert':
		dq.appendleft(com[1])
	elif com[0]=='deleteFirst':
		dq.popleft()
	elif com[0]=='deleteLast':
		dq.pop()
	else:
		if com[1] in dq:
			dq.remove(com[1]) com[0]=='insert' com[0] com 0 'insert' dq.appendleft(com[1]) dq.appendleft dq appendleft com[1] com 1 elif com[0]=='deleteFirst':
		dq.popleft()
	 com[0]=='deleteFirst' com[0] com 0 'deleteFirst' dq.popleft() dq.popleft dq popleft elif com[0]=='deleteLast':
		dq.pop()
	 com[0]=='deleteLast' com[0] com 0 'deleteLast' dq.pop() dq.pop dq pop if com[1] in dq:
			dq.remove(com[1]) com[1] in dq com[1] com 1 dq dq.remove(com[1]) dq.remove dq remove com[1] com 1 print(' '.join(dq)) print ' '.join(dq) ' '.join ' ' join dq dq=deque() deque() dq com=input().split() input().split() com n=int(input()) int(input()) n
from collections import deque

dq=deque()
n=int(input())

for i in range(n):
	com=input().split()
	if com[0]=='insert':
		dq.appendleft(com[1])
	elif com[0]=='deleteFirst':
		dq.popleft()
	elif com[0]=='deleteLast':
		dq.pop()
	else:
		if com[1] in dq:
			dq.remove(com[1])
print(' '.join(dq))