n = int(raw_input())
ls = []
bp = 0
for i in range(n):
	cmd = raw_input()
	if cmd[0] == "i":
		ls.append(cmd[7:])
	elif cmd[6] == " ":
		try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	elif cmd[6] == "F":
		ls.pop()
	else:
		bp += 1

print " ".join(map(str, ls[bp:][::-1])) n = int(raw_input()) n int(raw_input()) int raw_input() raw_input ls = [] ls [] bp = 0 bp 0 for i in range(n):
	cmd = raw_input()
	if cmd[0] == "i":
		ls.append(cmd[7:])
	elif cmd[6] == " ":
		try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	elif cmd[6] == "F":
		ls.pop()
	else:
		bp += 1 i range(n) range n cmd = raw_input() cmd raw_input() raw_input if cmd[0] == "i":
		ls.append(cmd[7:])
	elif cmd[6] == " ":
		try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	elif cmd[6] == "F":
		ls.pop()
	else:
		bp += 1 cmd[0] == "i" cmd[0] cmd 0 "i" ls.append(cmd[7:]) ls.append ls append cmd[7:] cmd 7: 7 elif cmd[6] == " ":
		try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	 cmd[6] == " " cmd[6] cmd 6 " " try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	 except:
			pass
	 x = ls[::-1].index(cmd[7:]) x ls[::-1].index(cmd[7:]) [::-1].index [::-1] ls ::-1 -1 index cmd[7:] cmd 7: 7 if x!=-1:
				del ls[-x-1]
		 x!=-1 x -1 del ls[-x-1] ls[-x-1] ls -x-1 -x x 1 elif cmd[6] == "F":
		ls.pop()
	 cmd[6] == "F" cmd[6] cmd 6 "F" ls.pop() ls.pop ls pop bp += 1 bp 1 print " ".join(map(str, ls[bp:][::-1])) " ".join " " join map(str, ls[bp:][::-1]) map str ls[bp:][::-1] [bp:] ls bp: bp ::-1 -1 bp = 0 0 bp bp += 1 1 bp ls = [] [] ls x = ls[::-1].index(cmd[7:]) ls[::-1].index(cmd[7:]) x n = int(raw_input()) int(raw_input()) n cmd = raw_input() raw_input() cmd
n = int(raw_input())
ls = []
bp = 0
for i in range(n):
	cmd = raw_input()
	if cmd[0] == "i":
		ls.append(cmd[7:])
	elif cmd[6] == " ":
		try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	elif cmd[6] == "F":
		ls.pop()
	else:
		bp += 1

print " ".join(map(str, ls[bp:][::-1]))