import sys
n = int(sys.stdin.readline())
lines = sys.stdin.readlines()
#n = int(input())
#import collections
#dll = collections.deque()
class Node:
  def __init__(self,v):
    self.val = v
    self.prev = None
    self.next = None
class DLL():
  def __init__(self):
    self.tail = Node(None)
    self.tail.next = self.tail
    self.tail.prev = self.tail
  def insert(self,x):
    n = Node(x)
    pre = self.tail.next
    n.next = pre
    n.prev = self.tail
    pre.prev = n
    self.tail.next = n
  def delete(self,x):
    node = self.tail.next
    while node != self.tail:
      if node.val == x:
        p = node.prev
        n = node.next
        p.next = n
        n.prev = p
        return
      node = node.next
  def deleteFirst(self):
    pre = self.tail.next
    if pre == self.tail:
      return
    node = self.tail.next
    p = node.prev
    n = node.next
    p.next = n
    n.prev = p
  def deleteLast(self):
    if self.tail.next == self.tail:
      return
    node = self.tail.prev
    p = node.prev
    n = node.next
    p.next = n
    n.prev = p
  def inspect(self):
    node = self.tail.next
    ret = []
    while node != self.tail:
      ret.append(str(node.val))
      node = node.next
    print(" ".join(ret))
dll=DLL()
for i in range(n):
  q = lines[i]
  if q[0] == "i":
      dll.insert(int(q.split()[1]))
  elif q[6] == " ":
      dll.delete(int(q.split()[1]))
  elif q[6] == "L":
      dll.deleteLast()
  elif q[6] == "F":
      dll.deleteFirst()
dll.inspect()
#print(" ".join(map(str,dll))) import sys sys n = int(sys.stdin.readline()) n int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline lines = sys.stdin.readlines() lines sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines class Node:
  def __init__(self,v):
    self.val = v
    self.prev = None
    self.next = None Node def __init__(self,v):
    self.val = v
    self.prev = None
    self.next = None __init__ self.val = v self.val self val v self.prev = None self.prev self prev None self.next = None self.next self next None self self v v class DLL():
  def __init__(self):
    self.tail = Node(None)
    self.tail.next = self.tail
    self.tail.prev = self.tail
  def insert(self,x):
    n = Node(x)
    pre = self.tail.next
    n.next = pre
    n.prev = self.tail
    pre.prev = n
    self.tail.next = n
  def delete(self,x):
    node = self.tail.next
    while node != self.tail:
      if node.val == x:
        p = node.prev
        n = node.next
        p.next = n
        n.prev = p
        return
      node = node.next
  def deleteFirst(self):
    pre = self.tail.next
    if pre == self.tail:
      return
    node = self.tail.next
    p = node.prev
    n = node.next
    p.next = n
    n.prev = p
  def deleteLast(self):
    if self.tail.next == self.tail:
      return
    node = self.tail.prev
    p = node.prev
    n = node.next
    p.next = n
    n.prev = p
  def inspect(self):
    node = self.tail.next
    ret = []
    while node != self.tail:
      ret.append(str(node.val))
      node = node.next
    print(" ".join(ret)) DLL def __init__(self):
    self.tail = Node(None)
    self.tail.next = self.tail
    self.tail.prev = self.tail
   __init__ self.tail = Node(None) self.tail self tail Node(None) Node None self.tail.next = self.tail self.tail.next self.tail self tail next self.tail self tail self.tail.prev = self.tail self.tail.prev self.tail self tail prev self.tail self tail self self def insert(self,x):
    n = Node(x)
    pre = self.tail.next
    n.next = pre
    n.prev = self.tail
    pre.prev = n
    self.tail.next = n
   insert n = Node(x) n Node(x) Node x pre = self.tail.next pre self.tail.next self.tail self tail next n.next = pre n.next n next pre n.prev = self.tail n.prev n prev self.tail self tail pre.prev = n pre.prev pre prev n self.tail.next = n self.tail.next self.tail self tail next n self self x x def delete(self,x):
    node = self.tail.next
    while node != self.tail:
      if node.val == x:
        p = node.prev
        n = node.next
        p.next = n
        n.prev = p
        return
      node = node.next
   delete node = self.tail.next node self.tail.next self.tail self tail next while node != self.tail:
      if node.val == x:
        p = node.prev
        n = node.next
        p.next = n
        n.prev = p
        return
      node = node.next
   node != self.tail node self.tail self tail if node.val == x:
        p = node.prev
        n = node.next
        p.next = n
        n.prev = p
        return
       node.val == x node.val node val x p = node.prev p node.prev node prev n = node.next n node.next node next p.next = n p.next p next n n.prev = p n.prev n prev p return node = node.next node node.next node next self self x x def deleteFirst(self):
    pre = self.tail.next
    if pre == self.tail:
      return
    node = self.tail.next
    p = node.prev
    n = node.next
    p.next = n
    n.prev = p
   deleteFirst pre = self.tail.next pre self.tail.next self.tail self tail next if pre == self.tail:
      return
     pre == self.tail pre self.tail self tail return node = self.tail.next node self.tail.next self.tail self tail next p = node.prev p node.prev node prev n = node.next n node.next node next p.next = n p.next p next n n.prev = p n.prev n prev p self self def deleteLast(self):
    if self.tail.next == self.tail:
      return
    node = self.tail.prev
    p = node.prev
    n = node.next
    p.next = n
    n.prev = p
   deleteLast if self.tail.next == self.tail:
      return
     self.tail.next == self.tail self.tail.next self.tail self tail next self.tail self tail return node = self.tail.prev node self.tail.prev self.tail self tail prev p = node.prev p node.prev node prev n = node.next n node.next node next p.next = n p.next p next n n.prev = p n.prev n prev p self self def inspect(self):
    node = self.tail.next
    ret = []
    while node != self.tail:
      ret.append(str(node.val))
      node = node.next
    print(" ".join(ret)) inspect node = self.tail.next node self.tail.next self.tail self tail next ret = [] ret [] while node != self.tail:
      ret.append(str(node.val))
      node = node.next
     node != self.tail node self.tail self tail ret.append(str(node.val)) ret.append ret append str(node.val) str node.val node val node = node.next node node.next node next print(" ".join(ret)) print " ".join(ret) " ".join " " join ret self self dll=DLL() dll DLL() DLL for i in range(n):
  q = lines[i]
  if q[0] == "i":
      dll.insert(int(q.split()[1]))
  elif q[6] == " ":
      dll.delete(int(q.split()[1]))
  elif q[6] == "L":
      dll.deleteLast()
  elif q[6] == "F":
      dll.deleteFirst() i range(n) range n q = lines[i] q lines[i] lines i if q[0] == "i":
      dll.insert(int(q.split()[1]))
  elif q[6] == " ":
      dll.delete(int(q.split()[1]))
  elif q[6] == "L":
      dll.deleteLast()
  elif q[6] == "F":
      dll.deleteFirst() q[0] == "i" q[0] q 0 "i" dll.insert(int(q.split()[1])) dll.insert dll insert int(q.split()[1]) int q.split()[1] q.split() q.split q split 1 elif q[6] == " ":
      dll.delete(int(q.split()[1]))
   q[6] == " " q[6] q 6 " " dll.delete(int(q.split()[1])) dll.delete dll delete int(q.split()[1]) int q.split()[1] q.split() q.split q split 1 elif q[6] == "L":
      dll.deleteLast()
   q[6] == "L" q[6] q 6 "L" dll.deleteLast() dll.deleteLast dll deleteLast elif q[6] == "F":
      dll.deleteFirst() q[6] == "F" q[6] q 6 "F" dll.deleteFirst() dll.deleteFirst dll deleteFirst dll.inspect() dll.inspect dll inspect q = lines[i] lines[i] q n = int(sys.stdin.readline()) int(sys.stdin.readline()) n class Node:
  def __init__(self,v):
    self.val = v
    self.prev = None
    self.next = None class Node:
  def __init__(self,v):
    self.val = v
    self.prev = None
    self.next = None Node class DLL():
  def __init__(self):
    self.tail = Node(None)
    self.tail.next = self.tail
    self.tail.prev = self.tail
  def insert(self,x):
    n = Node(x)
    pre = self.tail.next
    n.next = pre
    n.prev = self.tail
    pre.prev = n
    self.tail.next = n
  def delete(self,x):
    node = self.tail.next
    while node != self.tail:
      if node.val == x:
        p = node.prev
        n = node.next
        p.next = n
        n.prev = p
        return
      node = node.next
  def deleteFirst(self):
    pre = self.tail.next
    if pre == self.tail:
      return
    node = self.tail.next
    p = node.prev
    n = node.next
    p.next = n
    n.prev = p
  def deleteLast(self):
    if self.tail.next == self.tail:
      return
    node = self.tail.prev
    p = node.prev
    n = node.next
    p.next = n
    n.prev = p
  def inspect(self):
    node = self.tail.next
    ret = []
    while node != self.tail:
      ret.append(str(node.val))
      node = node.next
    print(" ".join(ret)) class DLL():
  def __init__(self):
    self.tail = Node(None)
    self.tail.next = self.tail
    self.tail.prev = self.tail
  def insert(self,x):
    n = Node(x)
    pre = self.tail.next
    n.next = pre
    n.prev = self.tail
    pre.prev = n
    self.tail.next = n
  def delete(self,x):
    node = self.tail.next
    while node != self.tail:
      if node.val == x:
        p = node.prev
        n = node.next
        p.next = n
        n.prev = p
        return
      node = node.next
  def deleteFirst(self):
    pre = self.tail.next
    if pre == self.tail:
      return
    node = self.tail.next
    p = node.prev
    n = node.next
    p.next = n
    n.prev = p
  def deleteLast(self):
    if self.tail.next == self.tail:
      return
    node = self.tail.prev
    p = node.prev
    n = node.next
    p.next = n
    n.prev = p
  def inspect(self):
    node = self.tail.next
    ret = []
    while node != self.tail:
      ret.append(str(node.val))
      node = node.next
    print(" ".join(ret)) DLL dll=DLL() DLL() dll lines = sys.stdin.readlines() sys.stdin.readlines() lines
import sys
n = int(sys.stdin.readline())
lines = sys.stdin.readlines()
#n = int(input())
#import collections
#dll = collections.deque()
class Node:
  def __init__(self,v):
    self.val = v
    self.prev = None
    self.next = None
class DLL():
  def __init__(self):
    self.tail = Node(None)
    self.tail.next = self.tail
    self.tail.prev = self.tail
  def insert(self,x):
    n = Node(x)
    pre = self.tail.next
    n.next = pre
    n.prev = self.tail
    pre.prev = n
    self.tail.next = n
  def delete(self,x):
    node = self.tail.next
    while node != self.tail:
      if node.val == x:
        p = node.prev
        n = node.next
        p.next = n
        n.prev = p
        return
      node = node.next
  def deleteFirst(self):
    pre = self.tail.next
    if pre == self.tail:
      return
    node = self.tail.next
    p = node.prev
    n = node.next
    p.next = n
    n.prev = p
  def deleteLast(self):
    if self.tail.next == self.tail:
      return
    node = self.tail.prev
    p = node.prev
    n = node.next
    p.next = n
    n.prev = p
  def inspect(self):
    node = self.tail.next
    ret = []
    while node != self.tail:
      ret.append(str(node.val))
      node = node.next
    print(" ".join(ret))
dll=DLL()
for i in range(n):
  q = lines[i]
  if q[0] == "i":
      dll.insert(int(q.split()[1]))
  elif q[6] == " ":
      dll.delete(int(q.split()[1]))
  elif q[6] == "L":
      dll.deleteLast()
  elif q[6] == "F":
      dll.deleteFirst()
dll.inspect()
#print(" ".join(map(str,dll)))
