n=gets.to_i
a=[]
n.times{
  a<<gets.split
}
c=[]
flag=false
check=0
while b=a.shift do
  flag=false
  case b[0]
  when "insert"
    c<<b[1]
  when "delete"
    c.each_with_index{|x,i|
      if b[1]==x
        check=i
        flag=true
      end
    }
    c.delete_at(check) if flag
  when "deleteFirst"
    c.pop
  when "deleteLast"
    c.shift
  end
end
puts c.reverse.join(" ")
