### BUGGY CODE ###

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

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

class Dlist:
    """ ??????????????????????????? """
    MAX = 1000000
    NoValue = -1
    Prev = 0
    Next = 1
    Value = 2

    def __init__(self):
        """ ????????????????????? """
        self.si = -1
        self.ei = -1
        self.pos = -1
        self.uniqid = 0
        self.cnt = 0
        self.items = []

    def __iter__(self):
        """ ????????¬?????? """
        self.pos = self.si
        return self

    def __next__(self):
        """ ?¬???????????????? """
        if self.cnt == 0: # ???????????????
            raise StopIteration()
        elif self.items[self.pos][Dlist.Next] == Dlist.NoValue: # ?¬??????????
            raise StopIteration()
        else:
            self.pos = self.items[self.pos][Dlist.Next]
        return self.items[self.pos]

 
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        if self.cnt == Dlist.MAX: # ??????????????????
            return -1

        t = [Dlist.NoValue, Dlist.NoValue, x]

        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            s = self.items[self.si]
            s[Dlist.Prev] = self.uniqid
            t[Dlist.Next] = self.si
        self.items.append(t)
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
        return t
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

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

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt > 0:
            n = self.items[self.si][Dlist.Next]
            if n != Dlist.NoValue:
                self.items[n][Dlist.Prev] = Dlist.NoValue
            self.items[self.si][Dlist.Value] = Dlist.NoValue
            self.si = n
            self.cnt -= 1
            if self.cnt < 1:
                self.ei = Dlist.NoValue

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt > 0:
            p = self.items[self.ei][Dlist.Prev]
            if p != Dlist.NoValue:
                self.items[p][Dlist.Next] = Dlist.NoValue
            self.items[self.ei][Dlist.Value] = Dlist.NoValue
            self.ei = p
            self.cnt -= 1
            if self.cnt < 1:
                self.si = Dlist.NoValue

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

    def debugList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != Dlist.NoValue:
                a.append("{} => {}".format(i,self.items[i][Dlist.Value]))
                i = self.items[i][Dlist.Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    dl = Dlist()

    istr = sys.stdin.read()
    cmds = list(istr.split("\n"))

    for i in range(num):
        cmd = list(cmds[i].split())
        if cmd[0] == "insert":
            dl.insert(cmd[1])
        elif cmd[0] == "delete":
            dl.delete(cmd[1])
        elif cmd[0] == "deleteFirst":
            dl.deleteFirst()
        elif cmd[0] == "deleteLast":
            dl.deleteLast()

#       print()
#       print(cmd)
#       print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#       print(dl.debugList())

    print(" ".join(map(str, dl.getList())))


if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/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()