from collections import deque

n = int(input())
C = [input() for i in range(n)]

A = deque([])
for c in C:
	if c == 'deleteFirst':
		A.popleft()
	elif c == 'deleteLast':
		A.pop()
	elif 'delete' in c:
		q = int(c[7:])
		if q in A:
			A.remove(q)
	elif 'insert' in c:
		q = int(c[7:])
		A.appendleft(q)

print(' '.join(map(str, A))) from collections import deque n = int(input()) n int(input()) int input() input input() for i in range(n) for i in range(n) i range(n) range n for i in range(n) input() input C = [input() for i in range(n)] C [input() for i in range(n)] A = deque([]) A deque([]) deque [] for c in C:
	if c == 'deleteFirst':
		A.popleft()
	elif c == 'deleteLast':
		A.pop()
	elif 'delete' in c:
		q = int(c[7:])
		if q in A:
			A.remove(q)
	elif 'insert' in c:
		q = int(c[7:])
		A.appendleft(q) c C if c == 'deleteFirst':
		A.popleft()
	elif c == 'deleteLast':
		A.pop()
	elif 'delete' in c:
		q = int(c[7:])
		if q in A:
			A.remove(q)
	elif 'insert' in c:
		q = int(c[7:])
		A.appendleft(q) c == 'deleteFirst' c 'deleteFirst' A.popleft() A.popleft A popleft elif c == 'deleteLast':
		A.pop()
	 c == 'deleteLast' c 'deleteLast' A.pop() A.pop A pop elif 'delete' in c:
		q = int(c[7:])
		if q in A:
			A.remove(q)
	 'delete' in c 'delete' c q = int(c[7:]) q int(c[7:]) int c[7:] c 7: 7 if q in A:
			A.remove(q)
	 q in A q A A.remove(q) A.remove A remove q elif 'insert' in c:
		q = int(c[7:])
		A.appendleft(q) 'insert' in c 'insert' c q = int(c[7:]) q int(c[7:]) int c[7:] c 7: 7 A.appendleft(q) A.appendleft A appendleft q print(' '.join(map(str, A))) print ' '.join(map(str, A)) ' '.join ' ' join map(str, A) map str A n = int(input()) int(input()) n A = deque([]) deque([]) A q = int(c[7:]) int(c[7:]) q q = int(c[7:]) int(c[7:]) q C = [input() for i in range(n)] [input() for i in range(n)] C
from collections import deque

n = int(input())
C = [input() for i in range(n)]

A = deque([])
for c in C:
	if c == 'deleteFirst':
		A.popleft()
	elif c == 'deleteLast':
		A.pop()
	elif 'delete' in c:
		q = int(c[7:])
		if q in A:
			A.remove(q)
	elif 'insert' in c:
		q = int(c[7:])
		A.appendleft(q)

print(' '.join(map(str, A)))
