from collections import deque

if __name__ == '__main__':
	n = int(input())
	L = deque()

	for i in range(n):
		cmdline = input().split()

		if cmdline[0] == "insert":
			L.appendleft(cmdline[1])
		elif cmdline[0] == "delete":
		    try:
			    L.remove(cmdline[1])
		    except ValueError:
			    pass
		elif cmdline[0] == "deleteFirst":
			L.popleft()
		elif cmdline[0] == "deleteLast":
			L.pop()

	print(" ".join(L))
 from collections import deque if __name__ == '__main__':
	n = int(input())
	L = deque()

	for i in range(n):
		cmdline = input().split()

		if cmdline[0] == "insert":
			L.appendleft(cmdline[1])
		elif cmdline[0] == "delete":
		    try:
			    L.remove(cmdline[1])
		    except ValueError:
			    pass
		elif cmdline[0] == "deleteFirst":
			L.popleft()
		elif cmdline[0] == "deleteLast":
			L.pop()

	print(" ".join(L)) __name__ == '__main__' __name__ '__main__' n = int(input()) n int(input()) int input() input L = deque() L deque() deque for i in range(n):
		cmdline = input().split()

		if cmdline[0] == "insert":
			L.appendleft(cmdline[1])
		elif cmdline[0] == "delete":
		    try:
			    L.remove(cmdline[1])
		    except ValueError:
			    pass
		elif cmdline[0] == "deleteFirst":
			L.popleft()
		elif cmdline[0] == "deleteLast":
			L.pop()

	 i range(n) range n cmdline = input().split() cmdline input().split() ().split () input split if cmdline[0] == "insert":
			L.appendleft(cmdline[1])
		elif cmdline[0] == "delete":
		    try:
			    L.remove(cmdline[1])
		    except ValueError:
			    pass
		elif cmdline[0] == "deleteFirst":
			L.popleft()
		elif cmdline[0] == "deleteLast":
			L.pop()

	 cmdline[0] == "insert" cmdline[0] cmdline 0 "insert" L.appendleft(cmdline[1]) L.appendleft L appendleft cmdline[1] cmdline 1 elif cmdline[0] == "delete":
		    try:
			    L.remove(cmdline[1])
		    except ValueError:
			    pass
		 cmdline[0] == "delete" cmdline[0] cmdline 0 "delete" try:
			    L.remove(cmdline[1])
		    except ValueError:
			    pass
		 except ValueError:
			    pass
		 L.remove(cmdline[1]) L.remove L remove cmdline[1] cmdline 1 elif cmdline[0] == "deleteFirst":
			L.popleft()
		 cmdline[0] == "deleteFirst" cmdline[0] cmdline 0 "deleteFirst" L.popleft() L.popleft L popleft elif cmdline[0] == "deleteLast":
			L.pop()

	 cmdline[0] == "deleteLast" cmdline[0] cmdline 0 "deleteLast" L.pop() L.pop L pop print(" ".join(L)) print " ".join(L) " ".join " " join L cmdline = input().split() input().split() cmdline n = int(input()) int(input()) n L = deque() deque() L
from collections import deque

if __name__ == '__main__':
	n = int(input())
	L = deque()

	for i in range(n):
		cmdline = input().split()

		if cmdline[0] == "insert":
			L.appendleft(cmdline[1])
		elif cmdline[0] == "delete":
		    try:
			    L.remove(cmdline[1])
		    except ValueError:
			    pass
		elif cmdline[0] == "deleteFirst":
			L.popleft()
		elif cmdline[0] == "deleteLast":
			L.pop()

	print(" ".join(L))

