import sys
from collections import deque

input()
d = deque()
for l in sys.stdin:
	s = l.split()
	if s[0] == 'insert':
		d.appendleft(s[1])
	elif s[0] == 'delete':
		try: d.remove(s[1])
		except: pass
	elif s[0] == 'deleteFirst':
		d.popleft()
	elif s[0] == 'deleteLast':
		d.pop()
print(*d) import sys sys from collections import deque input() input d = deque() d deque() deque for l in sys.stdin:
	s = l.split()
	if s[0] == 'insert':
		d.appendleft(s[1])
	elif s[0] == 'delete':
		try: d.remove(s[1])
		except: pass
	elif s[0] == 'deleteFirst':
		d.popleft()
	elif s[0] == 'deleteLast':
		d.pop() l sys.stdin sys stdin s = l.split() s l.split() l.split l split if s[0] == 'insert':
		d.appendleft(s[1])
	elif s[0] == 'delete':
		try: d.remove(s[1])
		except: pass
	elif s[0] == 'deleteFirst':
		d.popleft()
	elif s[0] == 'deleteLast':
		d.pop() s[0] == 'insert' s[0] s 0 'insert' d.appendleft(s[1]) d.appendleft d appendleft s[1] s 1 elif s[0] == 'delete':
		try: d.remove(s[1])
		except: pass
	 s[0] == 'delete' s[0] s 0 'delete' try: d.remove(s[1])
		except: pass
	 except: pass
	 elif s[0] == 'deleteFirst':
		d.popleft()
	 s[0] == 'deleteFirst' s[0] s 0 'deleteFirst' d.popleft() d.popleft d popleft elif s[0] == 'deleteLast':
		d.pop() s[0] == 'deleteLast' s[0] s 0 'deleteLast' d.pop() d.pop d pop print(*d) print *d d s = l.split() l.split() s d = deque() deque() d
import sys
from collections import deque

input()
d = deque()
for l in sys.stdin:
	s = l.split()
	if s[0] == 'insert':
		d.appendleft(s[1])
	elif s[0] == 'delete':
		try: d.remove(s[1])
		except: pass
	elif s[0] == 'deleteFirst':
		d.popleft()
	elif s[0] == 'deleteLast':
		d.pop()
print(*d)
