n = input()
array = []
base = 0
for i in range(n):
	inst = raw_input().split()
	if inst[0][0] == 'i':
		array.append(int(inst[1]))
	elif inst[0] == "delete":
		if int(inst[1]) in array:
			x = array[::-1].index(int(inst[1]))
			if x != -1 and int(inst[1]):
				del array[-x-1]
	elif inst[0][6] == 'F':
		array.pop()
	else:
		base += 1
print (" ".join(map(str,array[base:][::-1]))) n = input() n input() input array = [] array [] base = 0 base 0 for i in range(n):
	inst = raw_input().split()
	if inst[0][0] == 'i':
		array.append(int(inst[1]))
	elif inst[0] == "delete":
		if int(inst[1]) in array:
			x = array[::-1].index(int(inst[1]))
			if x != -1 and int(inst[1]):
				del array[-x-1]
	elif inst[0][6] == 'F':
		array.pop()
	else:
		base += 1 i range(n) range n inst = raw_input().split() inst raw_input().split() ().split () raw_input split if inst[0][0] == 'i':
		array.append(int(inst[1]))
	elif inst[0] == "delete":
		if int(inst[1]) in array:
			x = array[::-1].index(int(inst[1]))
			if x != -1 and int(inst[1]):
				del array[-x-1]
	elif inst[0][6] == 'F':
		array.pop()
	else:
		base += 1 inst[0][0] == 'i' inst[0][0] [0] inst 0 0 'i' array.append(int(inst[1])) array.append array append int(inst[1]) int inst[1] inst 1 elif inst[0] == "delete":
		if int(inst[1]) in array:
			x = array[::-1].index(int(inst[1]))
			if x != -1 and int(inst[1]):
				del array[-x-1]
	 inst[0] == "delete" inst[0] inst 0 "delete" if int(inst[1]) in array:
			x = array[::-1].index(int(inst[1]))
			if x != -1 and int(inst[1]):
				del array[-x-1]
	 int(inst[1]) in array int(inst[1]) int inst[1] inst 1 array x = array[::-1].index(int(inst[1])) x array[::-1].index(int(inst[1])) [::-1].index [::-1] array ::-1 -1 index int(inst[1]) int inst[1] inst 1 if x != -1 and int(inst[1]):
				del array[-x-1]
	 x != -1 and int(inst[1]) x != -1 x -1 int(inst[1]) int inst[1] inst 1 del array[-x-1] array[-x-1] array -x-1 -x x 1 elif inst[0][6] == 'F':
		array.pop()
	 inst[0][6] == 'F' inst[0][6] [0] inst 0 6 'F' array.pop() array.pop array pop base += 1 base 1 print (" ".join(map(str,array[base:][::-1]))) print " ".join(map(str,array[base:][::-1])) " ".join " " join map(str,array[base:][::-1]) map str array[base:][::-1] [base:] array base: base ::-1 -1 base += 1 1 base array = [] [] array base = 0 0 base n = input() input() n x = array[::-1].index(int(inst[1])) array[::-1].index(int(inst[1])) x inst = raw_input().split() raw_input().split() inst
n = input()
array = []
base = 0
for i in range(n):
	inst = raw_input().split()
	if inst[0][0] == 'i':
		array.append(int(inst[1]))
	elif inst[0] == "delete":
		if int(inst[1]) in array:
			x = array[::-1].index(int(inst[1]))
			if x != -1 and int(inst[1]):
				del array[-x-1]
	elif inst[0][6] == 'F':
		array.pop()
	else:
		base += 1
print (" ".join(map(str,array[base:][::-1])))