from collections import deque
num=int(input())
a=deque()
for i in range(num):
    tmp=input().split()
    if tmp[0]=="insert":
        a.appendleft(tmp[1])
    if tmp[0]=="delete":
        if tmp[1] in a:
            a.remove(tmp[1])
    if tmp[0]=="deleteFirst":
        a.popleft()
    if tmp[0]=="deleteLast":
        a.pop()
print(" ".join(a)) from collections import deque num=int(input()) num int(input()) int input() input a=deque() a deque() deque for i in range(num):
    tmp=input().split()
    if tmp[0]=="insert":
        a.appendleft(tmp[1])
    if tmp[0]=="delete":
        if tmp[1] in a:
            a.remove(tmp[1])
    if tmp[0]=="deleteFirst":
        a.popleft()
    if tmp[0]=="deleteLast":
        a.pop() i range(num) range num tmp=input().split() tmp input().split() ().split () input split if tmp[0]=="insert":
        a.appendleft(tmp[1])
     tmp[0]=="insert" tmp[0] tmp 0 "insert" a.appendleft(tmp[1]) a.appendleft a appendleft tmp[1] tmp 1 if tmp[0]=="delete":
        if tmp[1] in a:
            a.remove(tmp[1])
     tmp[0]=="delete" tmp[0] tmp 0 "delete" if tmp[1] in a:
            a.remove(tmp[1])
     tmp[1] in a tmp[1] tmp 1 a a.remove(tmp[1]) a.remove a remove tmp[1] tmp 1 if tmp[0]=="deleteFirst":
        a.popleft()
     tmp[0]=="deleteFirst" tmp[0] tmp 0 "deleteFirst" a.popleft() a.popleft a popleft if tmp[0]=="deleteLast":
        a.pop() tmp[0]=="deleteLast" tmp[0] tmp 0 "deleteLast" a.pop() a.pop a pop print(" ".join(a)) print " ".join(a) " ".join " " join a a=deque() deque() a tmp=input().split() input().split() tmp num=int(input()) int(input()) num
from collections import deque
num=int(input())
a=deque()
for i in range(num):
    tmp=input().split()
    if tmp[0]=="insert":
        a.appendleft(tmp[1])
    if tmp[0]=="delete":
        if tmp[1] in a:
            a.remove(tmp[1])
    if tmp[0]=="deleteFirst":
        a.popleft()
    if tmp[0]=="deleteLast":
        a.pop()
print(" ".join(a))
