### BUGGY CODE ###

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

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
class DListItem:
    NoValue = -1

    def __init__(self,idx,value):
        """ ????????????????????? """
        self.prev = DListItem.NoValue
        self.next = DListItem.NoValue
        self.value = value


class Dlist:
    MAX = 1000000
    
    def __init__(self):
        """ ????????????????????? """
        self.si = -1
        self.ei = -1
        self.pos = -1
        self.uniqid = 0
        self.cnt = 0
        self.items = {}

    def __iter__(self):
        """ ????????¬?????? """
        if self.cnt != 0:
            self.pos = self.si
        else:
            self.pos = -1

        return self

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

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

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

        t = DListItem(self.uniqid, x)

        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            s = self.items[self.si]
            s.prev = self.uniqid
            t.next = self.si
        self.items[self.uniqid] = 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 == DListItem.NoValue:
                    break
                if self.items[i].value == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        n = self.items[i].next
                        p = self.items[i].prev
                        self.items[n].prev = p
                        self.items[p].next = n
                        del self.items[i]
                        self.cnt -= 1
                else:
                    i = self.items[i].next

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt > 0:
            n = self.items[self.si].next
            if n != DListItem.NoValue:
                self.items[n].prev = DListItem.NoValue
            del self.items[self.si]
            self.si = n
            self.cnt -= 1
            if self.cnt < 1:
                self.ei = DListItem.NoValue

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt > 0:
            p = self.items[self.ei].prev
            if p != DListItem.NoValue:
                self.items[p].next = DListItem.NoValue
            del self.items[self.ei]
            self.ei = p
            self.cnt -= 1
            if self.cnt < 1:
                self.si = DListItem.NoValue

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != DListItem.NoValue:
                a.append(self.items[i].value)
                i = self.items[i].next
        return a

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

# ?????????
num = int(input().strip())
dl = Dlist()

for i in range(num):
    cmd = list(input().strip().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())))

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