class Cell:
    def __init__(self, x):
        self.x = x
        self.next = None
        self.prev = None

class DoublyLinkedList:
    def __init__(self):
        self.start = Cell(None)
        self.start.next = None
        self.start.prev = None

    def InsCell(self, x):
        new = Cell(x)
        if self.start.next != None:
            new.next = self.start.next
            self.start.next.prev = new
        else:
            self.start.prev = new
            new.next = self.start
        self.start.next = new
        new.prev = self.start

    def DelCell(self, x):
        tmp = self.start
        while tmp.x != x:
            if tmp.next == self.start:
                return
            tmp = tmp.next
        tmp.prev.next = tmp.next
        tmp.next.prev = tmp.prev
        tmp = None

    def DelFisrtCell(self):
        tmp = self.start.next
        if tmp.next == self.start:
            self.start.next = None
            self.start.prev = None
        else:
            self.start.next = tmp.next
            tmp.next.prev = self.start
        tmp = None

    def DelLastCell(self):
        tmp = self.start.prev
        if tmp.prev == self.start:
            self.start.next = None
            self.start.prev = None
        else:
            self.start.prev = tmp.prev
            tmp.prev.next = self.start
        tmp = None

    def PrintCell(self):
        ans = []
        tmp = self.start.next
        if tmp == None:
            print("")
        else:
            while tmp != self.start:
                ans.append(tmp.x)
                tmp = tmp.next
            print(" ".join(ans))

import sys
input = sys.stdin.readline

n = int(input())
l = DoublyLinkedList()

for _ in range(n):
    c = input().split()
    if c[0] == "insert":
        l.InsCell(c[1])
    elif c[0] == "delete":
        l.DelCell(c[1])
    elif c[0] == "deleteFirst":
        l.DelFisrtCell()
    elif c[0] == "deleteLast":
        l.DelLastCell()

l.PrintCell()
 class Cell:
    def __init__(self, x):
        self.x = x
        self.next = None
        self.prev = None Cell def __init__(self, x):
        self.x = x
        self.next = None
        self.prev = None __init__ self.x = x self.x self x x self.next = None self.next self next None self.prev = None self.prev self prev None self self x x class DoublyLinkedList:
    def __init__(self):
        self.start = Cell(None)
        self.start.next = None
        self.start.prev = None

    def InsCell(self, x):
        new = Cell(x)
        if self.start.next != None:
            new.next = self.start.next
            self.start.next.prev = new
        else:
            self.start.prev = new
            new.next = self.start
        self.start.next = new
        new.prev = self.start

    def DelCell(self, x):
        tmp = self.start
        while tmp.x != x:
            if tmp.next == self.start:
                return
            tmp = tmp.next
        tmp.prev.next = tmp.next
        tmp.next.prev = tmp.prev
        tmp = None

    def DelFisrtCell(self):
        tmp = self.start.next
        if tmp.next == self.start:
            self.start.next = None
            self.start.prev = None
        else:
            self.start.next = tmp.next
            tmp.next.prev = self.start
        tmp = None

    def DelLastCell(self):
        tmp = self.start.prev
        if tmp.prev == self.start:
            self.start.next = None
            self.start.prev = None
        else:
            self.start.prev = tmp.prev
            tmp.prev.next = self.start
        tmp = None

    def PrintCell(self):
        ans = []
        tmp = self.start.next
        if tmp == None:
            print("")
        else:
            while tmp != self.start:
                ans.append(tmp.x)
                tmp = tmp.next
            print(" ".join(ans)) DoublyLinkedList def __init__(self):
        self.start = Cell(None)
        self.start.next = None
        self.start.prev = None

     __init__ self.start = Cell(None) self.start self start Cell(None) Cell None self.start.next = None self.start.next self.start self start next None self.start.prev = None self.start.prev self.start self start prev None self self def InsCell(self, x):
        new = Cell(x)
        if self.start.next != None:
            new.next = self.start.next
            self.start.next.prev = new
        else:
            self.start.prev = new
            new.next = self.start
        self.start.next = new
        new.prev = self.start

     InsCell new = Cell(x) new Cell(x) Cell x if self.start.next != None:
            new.next = self.start.next
            self.start.next.prev = new
        else:
            self.start.prev = new
            new.next = self.start
         self.start.next != None self.start.next self.start self start next None new.next = self.start.next new.next new next self.start.next self.start self start next self.start.next.prev = new self.start.next.prev self.start.next self.start self start next prev new self.start.prev = new self.start.prev self.start self start prev new new.next = self.start new.next new next self.start self start self.start.next = new self.start.next self.start self start next new new.prev = self.start new.prev new prev self.start self start self self x x def DelCell(self, x):
        tmp = self.start
        while tmp.x != x:
            if tmp.next == self.start:
                return
            tmp = tmp.next
        tmp.prev.next = tmp.next
        tmp.next.prev = tmp.prev
        tmp = None

     DelCell tmp = self.start tmp self.start self start while tmp.x != x:
            if tmp.next == self.start:
                return
            tmp = tmp.next
         tmp.x != x tmp.x tmp x x if tmp.next == self.start:
                return
             tmp.next == self.start tmp.next tmp next self.start self start return tmp = tmp.next tmp tmp.next tmp next 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 tmp = None tmp None self self x x def DelFisrtCell(self):
        tmp = self.start.next
        if tmp.next == self.start:
            self.start.next = None
            self.start.prev = None
        else:
            self.start.next = tmp.next
            tmp.next.prev = self.start
        tmp = None

     DelFisrtCell tmp = self.start.next tmp self.start.next self.start self start next if tmp.next == self.start:
            self.start.next = None
            self.start.prev = None
        else:
            self.start.next = tmp.next
            tmp.next.prev = self.start
         tmp.next == self.start tmp.next tmp next self.start self start self.start.next = None self.start.next self.start self start next None self.start.prev = None self.start.prev self.start self start prev None self.start.next = tmp.next self.start.next self.start self start next tmp.next tmp next tmp.next.prev = self.start tmp.next.prev tmp.next tmp next prev self.start self start tmp = None tmp None self self def DelLastCell(self):
        tmp = self.start.prev
        if tmp.prev == self.start:
            self.start.next = None
            self.start.prev = None
        else:
            self.start.prev = tmp.prev
            tmp.prev.next = self.start
        tmp = None

     DelLastCell tmp = self.start.prev tmp self.start.prev self.start self start prev if tmp.prev == self.start:
            self.start.next = None
            self.start.prev = None
        else:
            self.start.prev = tmp.prev
            tmp.prev.next = self.start
         tmp.prev == self.start tmp.prev tmp prev self.start self start self.start.next = None self.start.next self.start self start next None self.start.prev = None self.start.prev self.start self start prev None self.start.prev = tmp.prev self.start.prev self.start self start prev tmp.prev tmp prev tmp.prev.next = self.start tmp.prev.next tmp.prev tmp prev next self.start self start tmp = None tmp None self self def PrintCell(self):
        ans = []
        tmp = self.start.next
        if tmp == None:
            print("")
        else:
            while tmp != self.start:
                ans.append(tmp.x)
                tmp = tmp.next
            print(" ".join(ans)) PrintCell ans = [] ans [] tmp = self.start.next tmp self.start.next self.start self start next if tmp == None:
            print("")
        else:
            while tmp != self.start:
                ans.append(tmp.x)
                tmp = tmp.next
            print(" ".join(ans)) tmp == None tmp None print("") print "" while tmp != self.start:
                ans.append(tmp.x)
                tmp = tmp.next
             tmp != self.start tmp self.start self start ans.append(tmp.x) ans.append ans append tmp.x tmp x tmp = tmp.next tmp tmp.next tmp next print(" ".join(ans)) print " ".join(ans) " ".join " " join ans self self import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n = int(input()) n int(input()) int input() input l = DoublyLinkedList() l DoublyLinkedList() DoublyLinkedList for _ in range(n):
    c = input().split()
    if c[0] == "insert":
        l.InsCell(c[1])
    elif c[0] == "delete":
        l.DelCell(c[1])
    elif c[0] == "deleteFirst":
        l.DelFisrtCell()
    elif c[0] == "deleteLast":
        l.DelLastCell() _ range(n) range n c = input().split() c input().split() ().split () input split if c[0] == "insert":
        l.InsCell(c[1])
    elif c[0] == "delete":
        l.DelCell(c[1])
    elif c[0] == "deleteFirst":
        l.DelFisrtCell()
    elif c[0] == "deleteLast":
        l.DelLastCell() c[0] == "insert" c[0] c 0 "insert" l.InsCell(c[1]) l.InsCell l InsCell c[1] c 1 elif c[0] == "delete":
        l.DelCell(c[1])
     c[0] == "delete" c[0] c 0 "delete" l.DelCell(c[1]) l.DelCell l DelCell c[1] c 1 elif c[0] == "deleteFirst":
        l.DelFisrtCell()
     c[0] == "deleteFirst" c[0] c 0 "deleteFirst" l.DelFisrtCell() l.DelFisrtCell l DelFisrtCell elif c[0] == "deleteLast":
        l.DelLastCell() c[0] == "deleteLast" c[0] c 0 "deleteLast" l.DelLastCell() l.DelLastCell l DelLastCell l.PrintCell() l.PrintCell l PrintCell c = input().split() input().split() c n = int(input()) int(input()) n class DoublyLinkedList:
    def __init__(self):
        self.start = Cell(None)
        self.start.next = None
        self.start.prev = None

    def InsCell(self, x):
        new = Cell(x)
        if self.start.next != None:
            new.next = self.start.next
            self.start.next.prev = new
        else:
            self.start.prev = new
            new.next = self.start
        self.start.next = new
        new.prev = self.start

    def DelCell(self, x):
        tmp = self.start
        while tmp.x != x:
            if tmp.next == self.start:
                return
            tmp = tmp.next
        tmp.prev.next = tmp.next
        tmp.next.prev = tmp.prev
        tmp = None

    def DelFisrtCell(self):
        tmp = self.start.next
        if tmp.next == self.start:
            self.start.next = None
            self.start.prev = None
        else:
            self.start.next = tmp.next
            tmp.next.prev = self.start
        tmp = None

    def DelLastCell(self):
        tmp = self.start.prev
        if tmp.prev == self.start:
            self.start.next = None
            self.start.prev = None
        else:
            self.start.prev = tmp.prev
            tmp.prev.next = self.start
        tmp = None

    def PrintCell(self):
        ans = []
        tmp = self.start.next
        if tmp == None:
            print("")
        else:
            while tmp != self.start:
                ans.append(tmp.x)
                tmp = tmp.next
            print(" ".join(ans)) class DoublyLinkedList:
    def __init__(self):
        self.start = Cell(None)
        self.start.next = None
        self.start.prev = None

    def InsCell(self, x):
        new = Cell(x)
        if self.start.next != None:
            new.next = self.start.next
            self.start.next.prev = new
        else:
            self.start.prev = new
            new.next = self.start
        self.start.next = new
        new.prev = self.start

    def DelCell(self, x):
        tmp = self.start
        while tmp.x != x:
            if tmp.next == self.start:
                return
            tmp = tmp.next
        tmp.prev.next = tmp.next
        tmp.next.prev = tmp.prev
        tmp = None

    def DelFisrtCell(self):
        tmp = self.start.next
        if tmp.next == self.start:
            self.start.next = None
            self.start.prev = None
        else:
            self.start.next = tmp.next
            tmp.next.prev = self.start
        tmp = None

    def DelLastCell(self):
        tmp = self.start.prev
        if tmp.prev == self.start:
            self.start.next = None
            self.start.prev = None
        else:
            self.start.prev = tmp.prev
            tmp.prev.next = self.start
        tmp = None

    def PrintCell(self):
        ans = []
        tmp = self.start.next
        if tmp == None:
            print("")
        else:
            while tmp != self.start:
                ans.append(tmp.x)
                tmp = tmp.next
            print(" ".join(ans)) DoublyLinkedList input = sys.stdin.readline sys.stdin.readline input class Cell:
    def __init__(self, x):
        self.x = x
        self.next = None
        self.prev = None class Cell:
    def __init__(self, x):
        self.x = x
        self.next = None
        self.prev = None Cell l = DoublyLinkedList() DoublyLinkedList() l
class Cell:
    def __init__(self, x):
        self.x = x
        self.next = None
        self.prev = None

class DoublyLinkedList:
    def __init__(self):
        self.start = Cell(None)
        self.start.next = None
        self.start.prev = None

    def InsCell(self, x):
        new = Cell(x)
        if self.start.next != None:
            new.next = self.start.next
            self.start.next.prev = new
        else:
            self.start.prev = new
            new.next = self.start
        self.start.next = new
        new.prev = self.start

    def DelCell(self, x):
        tmp = self.start
        while tmp.x != x:
            if tmp.next == self.start:
                return
            tmp = tmp.next
        tmp.prev.next = tmp.next
        tmp.next.prev = tmp.prev
        tmp = None

    def DelFisrtCell(self):
        tmp = self.start.next
        if tmp.next == self.start:
            self.start.next = None
            self.start.prev = None
        else:
            self.start.next = tmp.next
            tmp.next.prev = self.start
        tmp = None

    def DelLastCell(self):
        tmp = self.start.prev
        if tmp.prev == self.start:
            self.start.next = None
            self.start.prev = None
        else:
            self.start.prev = tmp.prev
            tmp.prev.next = self.start
        tmp = None

    def PrintCell(self):
        ans = []
        tmp = self.start.next
        if tmp == None:
            print("")
        else:
            while tmp != self.start:
                ans.append(tmp.x)
                tmp = tmp.next
            print(" ".join(ans))

import sys
input = sys.stdin.readline

n = int(input())
l = DoublyLinkedList()

for _ in range(n):
    c = input().split()
    if c[0] == "insert":
        l.InsCell(c[1])
    elif c[0] == "delete":
        l.DelCell(c[1])
    elif c[0] == "deleteFirst":
        l.DelFisrtCell()
    elif c[0] == "deleteLast":
        l.DelLastCell()

l.PrintCell()

