import sys
input = sys.stdin.readline

class Node:
  def __init__(self,key):
    self.key=key
    self.prev=None
    self.next=None

class LinkedList:
  first=None
  last=None
  current=first

  def insert(self,x):
    node=Node(x)
    self.current=node
    if self.first==None:
      self.first=node
      self.last=node
    else:
      self.first.prev=node
      node.next=self.first
      self.first=node
  
  def delete(self,x):
    if self.first==None:
      #print('Error')
      return
    if self.first==self.last and self.first.key==x:
      self.first=None
      self.current=None
      self.last=None
      return

    elif self.first.key==x:
      self.first.next.prev=None
      self.current=self.first.next
      self.first=self.first.next
      return

    tmp=self.first
    while tmp!=None:
      if self.last==tmp and tmp.key==x:
        self.last.prev.next=None
        self.last=self.last.prev
        break
      elif tmp.key==x:
        tmp.prev.next=tmp.next
        tmp.next.prev=tmp.prev
        break
      tmp=tmp.next

  def deleteFirst(self):
    if self.first==self.last:
      self.first=None
      self.last=None
      self.current=None
      return
    self.first.next.prev=None
    self.first=self.first.next
    self.current=self.first

  def deleteLast(self):
    if self.first==self.last:
      self.first=None
      self.last=None
      self.current=None
      return
    self.last.prev.next=None
    self.last=self.last.prev

  def next(self):
    if self.current==None:
      return None
    tmp=self.current
    self.current=self.current.next
    return tmp

if __name__ == '__main__':
  n=int(input())
  L=LinkedList()

  def answer():
    tmp=L.next()
    while tmp!=None:
      ans=tmp.key
      tmp=L.next()
      if tmp==None:
        print(ans)
      else:
        print(ans,end=' ')
    L.current=L.first

  for _ in range(n):
    S=input().split()
    #print('---')
    #print(*S)
    if S[0]=='insert':
      L.insert(S[1])
    elif S[0]=='delete':
      L.delete(S[1])
    elif S[0]=='deleteFirst':
      L.deleteFirst()
    elif S[0]=='deleteLast':
      L.deleteLast()
    #answer()
  answer()
 import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline class Node:
  def __init__(self,key):
    self.key=key
    self.prev=None
    self.next=None Node def __init__(self,key):
    self.key=key
    self.prev=None
    self.next=None __init__ self.key=key self.key self key key self.prev=None self.prev self prev None self.next=None self.next self next None self self key key class LinkedList:
  first=None
  last=None
  current=first

  def insert(self,x):
    node=Node(x)
    self.current=node
    if self.first==None:
      self.first=node
      self.last=node
    else:
      self.first.prev=node
      node.next=self.first
      self.first=node
  
  def delete(self,x):
    if self.first==None:
      #print('Error')
      return
    if self.first==self.last and self.first.key==x:
      self.first=None
      self.current=None
      self.last=None
      return

    elif self.first.key==x:
      self.first.next.prev=None
      self.current=self.first.next
      self.first=self.first.next
      return

    tmp=self.first
    while tmp!=None:
      if self.last==tmp and tmp.key==x:
        self.last.prev.next=None
        self.last=self.last.prev
        break
      elif tmp.key==x:
        tmp.prev.next=tmp.next
        tmp.next.prev=tmp.prev
        break
      tmp=tmp.next

  def deleteFirst(self):
    if self.first==self.last:
      self.first=None
      self.last=None
      self.current=None
      return
    self.first.next.prev=None
    self.first=self.first.next
    self.current=self.first

  def deleteLast(self):
    if self.first==self.last:
      self.first=None
      self.last=None
      self.current=None
      return
    self.last.prev.next=None
    self.last=self.last.prev

  def next(self):
    if self.current==None:
      return None
    tmp=self.current
    self.current=self.current.next
    return tmp LinkedList first=None first None last=None last None current=first current first def insert(self,x):
    node=Node(x)
    self.current=node
    if self.first==None:
      self.first=node
      self.last=node
    else:
      self.first.prev=node
      node.next=self.first
      self.first=node
  
   insert node=Node(x) node Node(x) Node x self.current=node self.current self current node if self.first==None:
      self.first=node
      self.last=node
    else:
      self.first.prev=node
      node.next=self.first
      self.first=node
  
   self.first==None self.first self first None self.first=node self.first self first node self.last=node self.last self last node self.first.prev=node self.first.prev self.first self first prev node node.next=self.first node.next node next self.first self first self.first=node self.first self first node self self x x def delete(self,x):
    if self.first==None:
      #print('Error')
      return
    if self.first==self.last and self.first.key==x:
      self.first=None
      self.current=None
      self.last=None
      return

    elif self.first.key==x:
      self.first.next.prev=None
      self.current=self.first.next
      self.first=self.first.next
      return

    tmp=self.first
    while tmp!=None:
      if self.last==tmp and tmp.key==x:
        self.last.prev.next=None
        self.last=self.last.prev
        break
      elif tmp.key==x:
        tmp.prev.next=tmp.next
        tmp.next.prev=tmp.prev
        break
      tmp=tmp.next

   delete if self.first==None:
      #print('Error')
      return
     self.first==None self.first self first None return if self.first==self.last and self.first.key==x:
      self.first=None
      self.current=None
      self.last=None
      return

    elif self.first.key==x:
      self.first.next.prev=None
      self.current=self.first.next
      self.first=self.first.next
      return

     self.first==self.last and self.first.key==x self.first==self.last self.first self first self.last self last self.first.key==x self.first.key self.first self first key x self.first=None self.first self first None self.current=None self.current self current None self.last=None self.last self last None return elif self.first.key==x:
      self.first.next.prev=None
      self.current=self.first.next
      self.first=self.first.next
      return

     self.first.key==x self.first.key self.first self first key x self.first.next.prev=None self.first.next.prev self.first.next self.first self first next prev None self.current=self.first.next self.current self current self.first.next self.first self first next self.first=self.first.next self.first self first self.first.next self.first self first next return tmp=self.first tmp self.first self first while tmp!=None:
      if self.last==tmp and tmp.key==x:
        self.last.prev.next=None
        self.last=self.last.prev
        break
      elif tmp.key==x:
        tmp.prev.next=tmp.next
        tmp.next.prev=tmp.prev
        break
      tmp=tmp.next

   tmp!=None tmp None if self.last==tmp and tmp.key==x:
        self.last.prev.next=None
        self.last=self.last.prev
        break
      elif tmp.key==x:
        tmp.prev.next=tmp.next
        tmp.next.prev=tmp.prev
        break
       self.last==tmp and tmp.key==x self.last==tmp self.last self last tmp tmp.key==x tmp.key tmp key x self.last.prev.next=None self.last.prev.next self.last.prev self.last self last prev next None self.last=self.last.prev self.last self last self.last.prev self.last self last prev break elif tmp.key==x:
        tmp.prev.next=tmp.next
        tmp.next.prev=tmp.prev
        break
       tmp.key==x tmp.key tmp key x tmp.prev.next=tmp.next tmp.prev.next tmp.prev tmp prev next tmp.next tmp next tmp.next.prev=tmp.prev tmp.next.prev tmp.next tmp next prev tmp.prev tmp prev break tmp=tmp.next tmp tmp.next tmp next self self x x def deleteFirst(self):
    if self.first==self.last:
      self.first=None
      self.last=None
      self.current=None
      return
    self.first.next.prev=None
    self.first=self.first.next
    self.current=self.first

   deleteFirst if self.first==self.last:
      self.first=None
      self.last=None
      self.current=None
      return
     self.first==self.last self.first self first self.last self last self.first=None self.first self first None self.last=None self.last self last None self.current=None self.current self current None return self.first.next.prev=None self.first.next.prev self.first.next self.first self first next prev None self.first=self.first.next self.first self first self.first.next self.first self first next self.current=self.first self.current self current self.first self first self self def deleteLast(self):
    if self.first==self.last:
      self.first=None
      self.last=None
      self.current=None
      return
    self.last.prev.next=None
    self.last=self.last.prev

   deleteLast if self.first==self.last:
      self.first=None
      self.last=None
      self.current=None
      return
     self.first==self.last self.first self first self.last self last self.first=None self.first self first None self.last=None self.last self last None self.current=None self.current self current None return self.last.prev.next=None self.last.prev.next self.last.prev self.last self last prev next None self.last=self.last.prev self.last self last self.last.prev self.last self last prev self self def next(self):
    if self.current==None:
      return None
    tmp=self.current
    self.current=self.current.next
    return tmp next if self.current==None:
      return None
     self.current==None self.current self current None return None None tmp=self.current tmp self.current self current self.current=self.current.next self.current self current self.current.next self.current self current next return tmp tmp self self if __name__ == '__main__':
  n=int(input())
  L=LinkedList()

  def answer():
    tmp=L.next()
    while tmp!=None:
      ans=tmp.key
      tmp=L.next()
      if tmp==None:
        print(ans)
      else:
        print(ans,end=' ')
    L.current=L.first

  for _ in range(n):
    S=input().split()
    #print('---')
    #print(*S)
    if S[0]=='insert':
      L.insert(S[1])
    elif S[0]=='delete':
      L.delete(S[1])
    elif S[0]=='deleteFirst':
      L.deleteFirst()
    elif S[0]=='deleteLast':
      L.deleteLast()
    #answer()
  answer() __name__ == '__main__' __name__ '__main__' n=int(input()) n int(input()) int input() input L=LinkedList() L LinkedList() LinkedList def answer():
    tmp=L.next()
    while tmp!=None:
      ans=tmp.key
      tmp=L.next()
      if tmp==None:
        print(ans)
      else:
        print(ans,end=' ')
    L.current=L.first

   answer tmp=L.next() tmp L.next() L.next L next while tmp!=None:
      ans=tmp.key
      tmp=L.next()
      if tmp==None:
        print(ans)
      else:
        print(ans,end=' ')
     tmp!=None tmp None ans=tmp.key ans tmp.key tmp key tmp=L.next() tmp L.next() L.next L next if tmp==None:
        print(ans)
      else:
        print(ans,end=' ')
     tmp==None tmp None print(ans) print ans print(ans,end=' ') print ans end=' ' end ' ' L.current=L.first L.current L current L.first L first for _ in range(n):
    S=input().split()
    #print('---')
    #print(*S)
    if S[0]=='insert':
      L.insert(S[1])
    elif S[0]=='delete':
      L.delete(S[1])
    elif S[0]=='deleteFirst':
      L.deleteFirst()
    elif S[0]=='deleteLast':
      L.deleteLast()
    #answer()
   _ range(n) range n S=input().split() S input().split() ().split () input split if S[0]=='insert':
      L.insert(S[1])
    elif S[0]=='delete':
      L.delete(S[1])
    elif S[0]=='deleteFirst':
      L.deleteFirst()
    elif S[0]=='deleteLast':
      L.deleteLast()
    #answer()
   S[0]=='insert' S[0] S 0 'insert' L.insert(S[1]) L.insert L insert S[1] S 1 elif S[0]=='delete':
      L.delete(S[1])
     S[0]=='delete' S[0] S 0 'delete' L.delete(S[1]) L.delete L delete S[1] S 1 elif S[0]=='deleteFirst':
      L.deleteFirst()
     S[0]=='deleteFirst' S[0] S 0 'deleteFirst' L.deleteFirst() L.deleteFirst L deleteFirst elif S[0]=='deleteLast':
      L.deleteLast()
    #answer()
   S[0]=='deleteLast' S[0] S 0 'deleteLast' L.deleteLast() L.deleteLast L deleteLast answer() answer L=LinkedList() LinkedList() L n=int(input()) int(input()) n class Node:
  def __init__(self,key):
    self.key=key
    self.prev=None
    self.next=None class Node:
  def __init__(self,key):
    self.key=key
    self.prev=None
    self.next=None Node input = sys.stdin.readline sys.stdin.readline input class LinkedList:
  first=None
  last=None
  current=first

  def insert(self,x):
    node=Node(x)
    self.current=node
    if self.first==None:
      self.first=node
      self.last=node
    else:
      self.first.prev=node
      node.next=self.first
      self.first=node
  
  def delete(self,x):
    if self.first==None:
      #print('Error')
      return
    if self.first==self.last and self.first.key==x:
      self.first=None
      self.current=None
      self.last=None
      return

    elif self.first.key==x:
      self.first.next.prev=None
      self.current=self.first.next
      self.first=self.first.next
      return

    tmp=self.first
    while tmp!=None:
      if self.last==tmp and tmp.key==x:
        self.last.prev.next=None
        self.last=self.last.prev
        break
      elif tmp.key==x:
        tmp.prev.next=tmp.next
        tmp.next.prev=tmp.prev
        break
      tmp=tmp.next

  def deleteFirst(self):
    if self.first==self.last:
      self.first=None
      self.last=None
      self.current=None
      return
    self.first.next.prev=None
    self.first=self.first.next
    self.current=self.first

  def deleteLast(self):
    if self.first==self.last:
      self.first=None
      self.last=None
      self.current=None
      return
    self.last.prev.next=None
    self.last=self.last.prev

  def next(self):
    if self.current==None:
      return None
    tmp=self.current
    self.current=self.current.next
    return tmp class LinkedList:
  first=None
  last=None
  current=first

  def insert(self,x):
    node=Node(x)
    self.current=node
    if self.first==None:
      self.first=node
      self.last=node
    else:
      self.first.prev=node
      node.next=self.first
      self.first=node
  
  def delete(self,x):
    if self.first==None:
      #print('Error')
      return
    if self.first==self.last and self.first.key==x:
      self.first=None
      self.current=None
      self.last=None
      return

    elif self.first.key==x:
      self.first.next.prev=None
      self.current=self.first.next
      self.first=self.first.next
      return

    tmp=self.first
    while tmp!=None:
      if self.last==tmp and tmp.key==x:
        self.last.prev.next=None
        self.last=self.last.prev
        break
      elif tmp.key==x:
        tmp.prev.next=tmp.next
        tmp.next.prev=tmp.prev
        break
      tmp=tmp.next

  def deleteFirst(self):
    if self.first==self.last:
      self.first=None
      self.last=None
      self.current=None
      return
    self.first.next.prev=None
    self.first=self.first.next
    self.current=self.first

  def deleteLast(self):
    if self.first==self.last:
      self.first=None
      self.last=None
      self.current=None
      return
    self.last.prev.next=None
    self.last=self.last.prev

  def next(self):
    if self.current==None:
      return None
    tmp=self.current
    self.current=self.current.next
    return tmp LinkedList S=input().split() input().split() S def answer():
    tmp=L.next()
    while tmp!=None:
      ans=tmp.key
      tmp=L.next()
      if tmp==None:
        print(ans)
      else:
        print(ans,end=' ')
    L.current=L.first

   def answer():
    tmp=L.next()
    while tmp!=None:
      ans=tmp.key
      tmp=L.next()
      if tmp==None:
        print(ans)
      else:
        print(ans,end=' ')
    L.current=L.first

   answer
import sys
input = sys.stdin.readline

class Node:
  def __init__(self,key):
    self.key=key
    self.prev=None
    self.next=None

class LinkedList:
  first=None
  last=None
  current=first

  def insert(self,x):
    node=Node(x)
    self.current=node
    if self.first==None:
      self.first=node
      self.last=node
    else:
      self.first.prev=node
      node.next=self.first
      self.first=node
  
  def delete(self,x):
    if self.first==None:
      #print('Error')
      return
    if self.first==self.last and self.first.key==x:
      self.first=None
      self.current=None
      self.last=None
      return

    elif self.first.key==x:
      self.first.next.prev=None
      self.current=self.first.next
      self.first=self.first.next
      return

    tmp=self.first
    while tmp!=None:
      if self.last==tmp and tmp.key==x:
        self.last.prev.next=None
        self.last=self.last.prev
        break
      elif tmp.key==x:
        tmp.prev.next=tmp.next
        tmp.next.prev=tmp.prev
        break
      tmp=tmp.next

  def deleteFirst(self):
    if self.first==self.last:
      self.first=None
      self.last=None
      self.current=None
      return
    self.first.next.prev=None
    self.first=self.first.next
    self.current=self.first

  def deleteLast(self):
    if self.first==self.last:
      self.first=None
      self.last=None
      self.current=None
      return
    self.last.prev.next=None
    self.last=self.last.prev

  def next(self):
    if self.current==None:
      return None
    tmp=self.current
    self.current=self.current.next
    return tmp

if __name__ == '__main__':
  n=int(input())
  L=LinkedList()

  def answer():
    tmp=L.next()
    while tmp!=None:
      ans=tmp.key
      tmp=L.next()
      if tmp==None:
        print(ans)
      else:
        print(ans,end=' ')
    L.current=L.first

  for _ in range(n):
    S=input().split()
    #print('---')
    #print(*S)
    if S[0]=='insert':
      L.insert(S[1])
    elif S[0]=='delete':
      L.delete(S[1])
    elif S[0]=='deleteFirst':
      L.deleteFirst()
    elif S[0]=='deleteLast':
      L.deleteLast()
    #answer()
  answer()

