from collections import deque
n = input()
d = deque()
for i in range(int(n)):
	command = input()
	if command[0] == 'i':
		d.appendleft(command[7:])
	else:
		if command[6] == " ":
			if  command[7:] in d:
				d.remove(command[7:])
		else:
			if command[6] == 'L':
				d.pop()
			else:
				d.popleft()
for _ in range(len(d)-1):
	print(d.popleft(), end=" ")
print(d.pop()) from collections import deque n = input() n input() input d = deque() d deque() deque for i in range(int(n)):
	command = input()
	if command[0] == 'i':
		d.appendleft(command[7:])
	else:
		if command[6] == " ":
			if  command[7:] in d:
				d.remove(command[7:])
		else:
			if command[6] == 'L':
				d.pop()
			else:
				d.popleft() i range(int(n)) range int(n) int n command = input() command input() input if command[0] == 'i':
		d.appendleft(command[7:])
	else:
		if command[6] == " ":
			if  command[7:] in d:
				d.remove(command[7:])
		else:
			if command[6] == 'L':
				d.pop()
			else:
				d.popleft() command[0] == 'i' command[0] command 0 'i' d.appendleft(command[7:]) d.appendleft d appendleft command[7:] command 7: 7 if command[6] == " ":
			if  command[7:] in d:
				d.remove(command[7:])
		else:
			if command[6] == 'L':
				d.pop()
			else:
				d.popleft() command[6] == " " command[6] command 6 " " if  command[7:] in d:
				d.remove(command[7:])
		 command[7:] in d command[7:] command 7: 7 d d.remove(command[7:]) d.remove d remove command[7:] command 7: 7 if command[6] == 'L':
				d.pop()
			else:
				d.popleft() command[6] == 'L' command[6] command 6 'L' d.pop() d.pop d pop d.popleft() d.popleft d popleft for _ in range(len(d)-1):
	print(d.popleft(), end=" ") _ range(len(d)-1) range len(d)-1 len(d) len d 1 print(d.popleft(), end=" ") print d.popleft() d.popleft d popleft end=" " end " " print(d.pop()) print d.pop() d.pop d pop command = input() input() command n = input() input() n d = deque() deque() d
from collections import deque
n = input()
d = deque()
for i in range(int(n)):
	command = input()
	if command[0] == 'i':
		d.appendleft(command[7:])
	else:
		if command[6] == " ":
			if  command[7:] in d:
				d.remove(command[7:])
		else:
			if command[6] == 'L':
				d.pop()
			else:
				d.popleft()
for _ in range(len(d)-1):
	print(d.popleft(), end=" ")
print(d.pop())