#!/usr/bin/env python
#-*- coding:utf-8 -*-
from collections import deque

def parse_cmd(deque,input_cmd):
	if input_cmd[0] == 'insert':
		deque.appendleft(input_cmd[1])
	elif input_cmd[0] == 'delete':
		try:
			deque.remove(input_cmd[1])
		except:
			pass
	elif input_cmd[0] == 'deleteFirst':
		deque.popleft()
	elif input_cmd[0] == 'deleteLast':
		deque.pop()
		
def main():
	que = deque()
	n = int(raw_input())
	cmd = [raw_input().split() for _ in range(n)]
	
	for i in cmd:
		parse_cmd(que,i)
	
	print " ".join(que)


#def test():

if __name__ == '__main__':
	main()
	#test() from collections import deque def parse_cmd(deque,input_cmd):
	if input_cmd[0] == 'insert':
		deque.appendleft(input_cmd[1])
	elif input_cmd[0] == 'delete':
		try:
			deque.remove(input_cmd[1])
		except:
			pass
	elif input_cmd[0] == 'deleteFirst':
		deque.popleft()
	elif input_cmd[0] == 'deleteLast':
		deque.pop()
		 parse_cmd if input_cmd[0] == 'insert':
		deque.appendleft(input_cmd[1])
	elif input_cmd[0] == 'delete':
		try:
			deque.remove(input_cmd[1])
		except:
			pass
	elif input_cmd[0] == 'deleteFirst':
		deque.popleft()
	elif input_cmd[0] == 'deleteLast':
		deque.pop()
		 input_cmd[0] == 'insert' input_cmd[0] input_cmd 0 'insert' deque.appendleft(input_cmd[1]) deque.appendleft deque appendleft input_cmd[1] input_cmd 1 elif input_cmd[0] == 'delete':
		try:
			deque.remove(input_cmd[1])
		except:
			pass
	 input_cmd[0] == 'delete' input_cmd[0] input_cmd 0 'delete' try:
			deque.remove(input_cmd[1])
		except:
			pass
	 except:
			pass
	 deque.remove(input_cmd[1]) deque.remove deque remove input_cmd[1] input_cmd 1 elif input_cmd[0] == 'deleteFirst':
		deque.popleft()
	 input_cmd[0] == 'deleteFirst' input_cmd[0] input_cmd 0 'deleteFirst' deque.popleft() deque.popleft deque popleft elif input_cmd[0] == 'deleteLast':
		deque.pop()
		 input_cmd[0] == 'deleteLast' input_cmd[0] input_cmd 0 'deleteLast' deque.pop() deque.pop deque pop deque deque input_cmd input_cmd def main():
	que = deque()
	n = int(raw_input())
	cmd = [raw_input().split() for _ in range(n)]
	
	for i in cmd:
		parse_cmd(que,i)
	
	print " ".join(que)


#def test(): main que = deque() que deque() deque n = int(raw_input()) n int(raw_input()) int raw_input() raw_input raw_input().split() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) raw_input().split() ().split () raw_input split cmd = [raw_input().split() for _ in range(n)] cmd [raw_input().split() for _ in range(n)] for i in cmd:
		parse_cmd(que,i)
	
	 i cmd parse_cmd(que,i) parse_cmd que i print " ".join(que) " ".join " " join que if __name__ == '__main__':
	main()
	#test() __name__ == '__main__' __name__ '__main__' main() main def main():
	que = deque()
	n = int(raw_input())
	cmd = [raw_input().split() for _ in range(n)]
	
	for i in cmd:
		parse_cmd(que,i)
	
	print " ".join(que)


#def test(): def main():
	que = deque()
	n = int(raw_input())
	cmd = [raw_input().split() for _ in range(n)]
	
	for i in cmd:
		parse_cmd(que,i)
	
	print " ".join(que)


#def test(): main def parse_cmd(deque,input_cmd):
	if input_cmd[0] == 'insert':
		deque.appendleft(input_cmd[1])
	elif input_cmd[0] == 'delete':
		try:
			deque.remove(input_cmd[1])
		except:
			pass
	elif input_cmd[0] == 'deleteFirst':
		deque.popleft()
	elif input_cmd[0] == 'deleteLast':
		deque.pop()
		 def parse_cmd(deque,input_cmd):
	if input_cmd[0] == 'insert':
		deque.appendleft(input_cmd[1])
	elif input_cmd[0] == 'delete':
		try:
			deque.remove(input_cmd[1])
		except:
			pass
	elif input_cmd[0] == 'deleteFirst':
		deque.popleft()
	elif input_cmd[0] == 'deleteLast':
		deque.pop()
		 parse_cmd
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from collections import deque

def parse_cmd(deque,input_cmd):
	if input_cmd[0] == 'insert':
		deque.appendleft(input_cmd[1])
	elif input_cmd[0] == 'delete':
		try:
			deque.remove(input_cmd[1])
		except:
			pass
	elif input_cmd[0] == 'deleteFirst':
		deque.popleft()
	elif input_cmd[0] == 'deleteLast':
		deque.pop()
		
def main():
	que = deque()
	n = int(raw_input())
	cmd = [raw_input().split() for _ in range(n)]
	
	for i in cmd:
		parse_cmd(que,i)
	
	print " ".join(que)


#def test():

if __name__ == '__main__':
	main()
	#test()