#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????£????????????
??\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

NoValue = -1
Prev = 0
Next = 1
Value = 2

class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main() """
???????????£????????????
??\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
""" import sys sys NoValue = -1 NoValue -1 Prev = 0 Prev 0 Next = 1 Next 1 Value = 2 Value 2 class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a Dlist """ ??????????????????????????? """ def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

     __init__ """ ????????????????????? """ self.items = [0] * 2000000 self.items self items [0] * 2000000 [0] 0 2000000 self.clear() self.clear self clear self self def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
     clear """ ????´?????????????????????¢ """ self.si = NoValue self.si self si NoValue self.ei = NoValue self.ei self ei NoValue self.pos = NoValue self.pos self pos NoValue self.uniqid = 0 self.uniqid self uniqid 0 self.cnt = 0 self.cnt self cnt 0 self self def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
     insert """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """ n = NoValue n NoValue if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
         self.cnt == 0 self.cnt self cnt 0 self.ei = self.uniqid self.ei self ei self.uniqid self uniqid self.items[self.si][Prev] = self.uniqid self.items[self.si][Prev] self.items[self.si] self.items self items self.si self si Prev self.uniqid self uniqid n = self.si n self.si self si self.items[self.uniqid] = [NoValue, n, x] self.items[self.uniqid] self.items self items self.uniqid self uniqid [NoValue, n, x] NoValue n x self.si = self.uniqid self.si self si self.uniqid self uniqid self.uniqid += 1 self.uniqid self uniqid 1 self.cnt += 1 self.cnt self cnt 1 self self x x def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

     delete """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????""" if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

     self.cnt > 0 self.cnt self cnt 0 hit = False hit False i = self.si i self.si self si while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

     hit == False hit False if i == -1:
                    break
                 i == -1 i -1 break if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

     self.items[i][Value] == x self.items[i][Value] self.items[i] self.items self items i Value x hit = True hit True if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                 i == self.si i self.si self si self.deleteFirst() self.deleteFirst self deleteFirst elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                     i == self.ei i self.ei self ei self.deleteLast() self.deleteLast self deleteLast p = self.items[i][Prev] p self.items[i][Prev] self.items[i] self.items self items i Prev n = self.items[i][Next] n self.items[i][Next] self.items[i] self.items self items i Next self.items[n][Prev] = p self.items[n][Prev] self.items[n] self.items self items n Prev p self.items[p][Next] = n self.items[p][Next] self.items[p] self.items self items p Next n self.cnt -= 1 self.cnt self cnt 1 i = self.items[i][Next] i self.items[i][Next] self.items[i] self.items self items i Next self self x x def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

     deleteFirst """ ?????????????????????????´???????????????? """ if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

     self.cnt < 2 self.cnt self cnt 2 self.clear() self.clear self clear n = self.items[self.si][Next] n self.items[self.si][Next] self.items[self.si] self.items self items self.si self si Next if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
             n != NoValue n NoValue self.items[n][Prev] = NoValue self.items[n][Prev] self.items[n] self.items self items n Prev NoValue self.si = n self.si self si n self.cnt -= 1 self.cnt self cnt 1 self self def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

     deleteLast """ ????????????????°????????´???????????????????""" if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

     self.cnt < 2 self.cnt self cnt 2 self.clear() self.clear self clear p = self.items[self.ei][Prev] p self.items[self.ei][Prev] self.items[self.ei] self.items self items self.ei self ei Prev if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
             p != -1 p -1 self.items[p][Next] = NoValue self.items[p][Next] self.items[p] self.items self items p Next NoValue self.ei = p self.ei self ei p self.cnt -= 1 self.cnt self cnt 1 self self def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a getList a = [] a [] if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
         self.cnt > 0 self.cnt self cnt 0 i = self.si i self.si self si while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
         i != -1 i -1 a.append(self.items[i][Value]) a.append a append self.items[i][Value] self.items[i] self.items self items i Value i = self.items[i][Next] i self.items[i][Next] self.items[i] self.items self items i Next return a a self self def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList())) main """ ????????? """ num = int(input().strip()) num int(input().strip()) int input().strip() ().strip () input strip istr = sys.stdin.read() istr sys.stdin.read() sys.stdin.read sys.stdin sys stdin read cmds = list(istr.splitlines()) cmds list(istr.splitlines()) list istr.splitlines() istr.splitlines istr splitlines dl = Dlist() dl Dlist() Dlist for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

     i cmds if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

     i[6] == "F" i[6] i 6 "F" dl.deleteFirst() dl.deleteFirst dl deleteFirst elif i[6] == "L":
            dl.deleteLast()
         i[6] == "L" i[6] i 6 "L" dl.deleteLast() dl.deleteLast dl deleteLast elif i[0] == "i":
            dl.insert(i[7:])
         i[0] == "i" i[0] i 0 "i" dl.insert(i[7:]) dl.insert dl insert i[7:] i 7: 7 elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

     i[0] == "d" i[0] i 0 "d" dl.delete(i[7:]) dl.delete dl delete i[7:] i 7: 7 print(" ".join(dl.getList())) print " ".join(dl.getList()) " ".join " " join dl.getList() dl.getList dl getList if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main Prev = 0 0 Prev NoValue = -1 -1 NoValue def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList())) def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList())) main class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a Dlist Next = 1 1 Next Value = 2 2 Value
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????£????????????
??\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

NoValue = -1
Prev = 0
Next = 1
Value = 2

class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main()