import sys

class Node: 
    def __init__(self, x, y = None, z = None): 
        self.data = x 
        self.prev = y 
        self.next = z 

class LinkedList: 
    def __init__(self): 
        self.top = Node(None) 
        self.top.next = self.top
        self.top.prev = self.top
    def insert(self, x):
        a = Node(x)
        self.top.next.prev = a
        a.next = self.top.next
        self.top.next = a
        a.prev = self.top
    def search(self, x):
        nil = self.top
        node = nil.next
        while node != nil and node.data != x:
            node = node.next
        return node
    def _delete(self, node):
        if node != self.top:
            np = node.prev
            nn = node.next
            np.next = nn
            nn.prev = np
    def delete_data(self, x):
        node = self.search(x)
        self._delete(node)
    def deleteFirst(self):
        nil = self.top
        self._delete(nil.next)
    def deleteLast(self):
        nil = self.top
        self._delete(nil.prev)
    def output(self):
        nil = self.top
        node = nil.next
        datalist = []
        while node != nil:
            datalist.append(node.data)
            node = node.next
        print(" ".join(datalist))

n = int(input()) 
L = LinkedList()
nil = L.top
for cmd in sys.stdin:
    cmd = cmd.strip("\n")
    if "insert" in cmd:
        L.insert(cmd[7:])
    elif "deleteFirst" in cmd:
        L.deleteFirst()
    elif "deleteLast" in cmd: 
        L.deleteLast()
    elif "delete " in cmd:
        L.delete_data(cmd[7:])

L.output() import sys sys class Node: 
    def __init__(self, x, y = None, z = None): 
        self.data = x 
        self.prev = y 
        self.next = z  Node def __init__(self, x, y = None, z = None): 
        self.data = x 
        self.prev = y 
        self.next = z  __init__ self.data = x self.data self data x self.prev = y self.prev self prev y self.next = z self.next self next z self self x x y = None y None z = None z None class LinkedList: 
    def __init__(self): 
        self.top = Node(None) 
        self.top.next = self.top
        self.top.prev = self.top
    def insert(self, x):
        a = Node(x)
        self.top.next.prev = a
        a.next = self.top.next
        self.top.next = a
        a.prev = self.top
    def search(self, x):
        nil = self.top
        node = nil.next
        while node != nil and node.data != x:
            node = node.next
        return node
    def _delete(self, node):
        if node != self.top:
            np = node.prev
            nn = node.next
            np.next = nn
            nn.prev = np
    def delete_data(self, x):
        node = self.search(x)
        self._delete(node)
    def deleteFirst(self):
        nil = self.top
        self._delete(nil.next)
    def deleteLast(self):
        nil = self.top
        self._delete(nil.prev)
    def output(self):
        nil = self.top
        node = nil.next
        datalist = []
        while node != nil:
            datalist.append(node.data)
            node = node.next
        print(" ".join(datalist)) LinkedList def __init__(self): 
        self.top = Node(None) 
        self.top.next = self.top
        self.top.prev = self.top
     __init__ self.top = Node(None) self.top self top Node(None) Node None self.top.next = self.top self.top.next self.top self top next self.top self top self.top.prev = self.top self.top.prev self.top self top prev self.top self top self self def insert(self, x):
        a = Node(x)
        self.top.next.prev = a
        a.next = self.top.next
        self.top.next = a
        a.prev = self.top
     insert a = Node(x) a Node(x) Node x self.top.next.prev = a self.top.next.prev self.top.next self.top self top next prev a a.next = self.top.next a.next a next self.top.next self.top self top next self.top.next = a self.top.next self.top self top next a a.prev = self.top a.prev a prev self.top self top self self x x def search(self, x):
        nil = self.top
        node = nil.next
        while node != nil and node.data != x:
            node = node.next
        return node
     search nil = self.top nil self.top self top node = nil.next node nil.next nil next while node != nil and node.data != x:
            node = node.next
         node != nil and node.data != x node != nil node nil node.data != x node.data node data x node = node.next node node.next node next return node node self self x x def _delete(self, node):
        if node != self.top:
            np = node.prev
            nn = node.next
            np.next = nn
            nn.prev = np
     _delete if node != self.top:
            np = node.prev
            nn = node.next
            np.next = nn
            nn.prev = np
     node != self.top node self.top self top np = node.prev np node.prev node prev nn = node.next nn node.next node next np.next = nn np.next np next nn nn.prev = np nn.prev nn prev np self self node node def delete_data(self, x):
        node = self.search(x)
        self._delete(node)
     delete_data node = self.search(x) node self.search(x) self.search self search x self._delete(node) self._delete self _delete node self self x x def deleteFirst(self):
        nil = self.top
        self._delete(nil.next)
     deleteFirst nil = self.top nil self.top self top self._delete(nil.next) self._delete self _delete nil.next nil next self self def deleteLast(self):
        nil = self.top
        self._delete(nil.prev)
     deleteLast nil = self.top nil self.top self top self._delete(nil.prev) self._delete self _delete nil.prev nil prev self self def output(self):
        nil = self.top
        node = nil.next
        datalist = []
        while node != nil:
            datalist.append(node.data)
            node = node.next
        print(" ".join(datalist)) output nil = self.top nil self.top self top node = nil.next node nil.next nil next datalist = [] datalist [] while node != nil:
            datalist.append(node.data)
            node = node.next
         node != nil node nil datalist.append(node.data) datalist.append datalist append node.data node data node = node.next node node.next node next print(" ".join(datalist)) print " ".join(datalist) " ".join " " join datalist self self n = int(input()) n int(input()) int input() input L = LinkedList() L LinkedList() LinkedList nil = L.top nil L.top L top for cmd in sys.stdin:
    cmd = cmd.strip("\n")
    if "insert" in cmd:
        L.insert(cmd[7:])
    elif "deleteFirst" in cmd:
        L.deleteFirst()
    elif "deleteLast" in cmd: 
        L.deleteLast()
    elif "delete " in cmd:
        L.delete_data(cmd[7:]) cmd sys.stdin sys stdin cmd = cmd.strip("\n") cmd cmd.strip("\n") cmd.strip cmd strip "\n" if "insert" in cmd:
        L.insert(cmd[7:])
    elif "deleteFirst" in cmd:
        L.deleteFirst()
    elif "deleteLast" in cmd: 
        L.deleteLast()
    elif "delete " in cmd:
        L.delete_data(cmd[7:]) "insert" in cmd "insert" cmd L.insert(cmd[7:]) L.insert L insert cmd[7:] cmd 7: 7 elif "deleteFirst" in cmd:
        L.deleteFirst()
     "deleteFirst" in cmd "deleteFirst" cmd L.deleteFirst() L.deleteFirst L deleteFirst elif "deleteLast" in cmd: 
        L.deleteLast()
     "deleteLast" in cmd "deleteLast" cmd L.deleteLast() L.deleteLast L deleteLast elif "delete " in cmd:
        L.delete_data(cmd[7:]) "delete " in cmd "delete " cmd L.delete_data(cmd[7:]) L.delete_data L delete_data cmd[7:] cmd 7: 7 L.output() L.output L output n = int(input()) int(input()) n cmd = cmd.strip("\n") cmd.strip("\n") cmd class Node: 
    def __init__(self, x, y = None, z = None): 
        self.data = x 
        self.prev = y 
        self.next = z  class Node: 
    def __init__(self, x, y = None, z = None): 
        self.data = x 
        self.prev = y 
        self.next = z  Node L = LinkedList() LinkedList() L class LinkedList: 
    def __init__(self): 
        self.top = Node(None) 
        self.top.next = self.top
        self.top.prev = self.top
    def insert(self, x):
        a = Node(x)
        self.top.next.prev = a
        a.next = self.top.next
        self.top.next = a
        a.prev = self.top
    def search(self, x):
        nil = self.top
        node = nil.next
        while node != nil and node.data != x:
            node = node.next
        return node
    def _delete(self, node):
        if node != self.top:
            np = node.prev
            nn = node.next
            np.next = nn
            nn.prev = np
    def delete_data(self, x):
        node = self.search(x)
        self._delete(node)
    def deleteFirst(self):
        nil = self.top
        self._delete(nil.next)
    def deleteLast(self):
        nil = self.top
        self._delete(nil.prev)
    def output(self):
        nil = self.top
        node = nil.next
        datalist = []
        while node != nil:
            datalist.append(node.data)
            node = node.next
        print(" ".join(datalist)) class LinkedList: 
    def __init__(self): 
        self.top = Node(None) 
        self.top.next = self.top
        self.top.prev = self.top
    def insert(self, x):
        a = Node(x)
        self.top.next.prev = a
        a.next = self.top.next
        self.top.next = a
        a.prev = self.top
    def search(self, x):
        nil = self.top
        node = nil.next
        while node != nil and node.data != x:
            node = node.next
        return node
    def _delete(self, node):
        if node != self.top:
            np = node.prev
            nn = node.next
            np.next = nn
            nn.prev = np
    def delete_data(self, x):
        node = self.search(x)
        self._delete(node)
    def deleteFirst(self):
        nil = self.top
        self._delete(nil.next)
    def deleteLast(self):
        nil = self.top
        self._delete(nil.prev)
    def output(self):
        nil = self.top
        node = nil.next
        datalist = []
        while node != nil:
            datalist.append(node.data)
            node = node.next
        print(" ".join(datalist)) LinkedList nil = L.top L.top nil
import sys

class Node: 
    def __init__(self, x, y = None, z = None): 
        self.data = x 
        self.prev = y 
        self.next = z 

class LinkedList: 
    def __init__(self): 
        self.top = Node(None) 
        self.top.next = self.top
        self.top.prev = self.top
    def insert(self, x):
        a = Node(x)
        self.top.next.prev = a
        a.next = self.top.next
        self.top.next = a
        a.prev = self.top
    def search(self, x):
        nil = self.top
        node = nil.next
        while node != nil and node.data != x:
            node = node.next
        return node
    def _delete(self, node):
        if node != self.top:
            np = node.prev
            nn = node.next
            np.next = nn
            nn.prev = np
    def delete_data(self, x):
        node = self.search(x)
        self._delete(node)
    def deleteFirst(self):
        nil = self.top
        self._delete(nil.next)
    def deleteLast(self):
        nil = self.top
        self._delete(nil.prev)
    def output(self):
        nil = self.top
        node = nil.next
        datalist = []
        while node != nil:
            datalist.append(node.data)
            node = node.next
        print(" ".join(datalist))

n = int(input()) 
L = LinkedList()
nil = L.top
for cmd in sys.stdin:
    cmd = cmd.strip("\n")
    if "insert" in cmd:
        L.insert(cmd[7:])
    elif "deleteFirst" in cmd:
        L.deleteFirst()
    elif "deleteLast" in cmd: 
        L.deleteLast()
    elif "delete " in cmd:
        L.delete_data(cmd[7:])

L.output()
