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

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

class Dlist:
    MAX = 1000000
    
    def __init__(self):
        """ ????????????????????? """
        self.si = 0
        self.ei = 0
        self.cnt = 0
        self.data = [0 for r in range(Dlist.MAX)]

    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """
        self.si -= 1
        if self.si < 0:
            self.si = Dlist.MAX - 1
        self.data[self.si] = x
        self.cnt += 1

    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""
        if self.cnt > 0:
            self.hit = False
            for i in range(self.cnt):
                pi = self.si + i
                if pi >= Dlist.MAX:
                    pi -= Dlist.MAX
                if self.data[pi] == x:
                    hit = True
                    break
            if hit == True:
                for j in range(i, self.cnt):
                    pi = self.si + j
                    if pi >= Dlist.MAX:
                        pi -= Dlist.MAX
                    ni = pi + 1
                    if ni >= Dlist.MAX:
                        ni -= Dlist.MAX
                    self.data[pi] = self.data[ni]
                self.ei -= 1
                if self.ei < 0 :
                    self.ei = Dlist.MAX - 1
                self.cnt -= 1
            
    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt > 0:
            self.data[self.si] = 0
            self.si += 1
            if self.si >= Dlist.MAX:
                self.si = 0
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt > 0:
            self.ei -= 1
            if self.ei < 0 :
                self.ei = Dlist.MAX - 1
            self.data[self.ei] = 0
            self.cnt -= 1

    def getList(self):
        return self.data[self.si:self.ei]

# ?????????
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("cmd={} si={} ei={} cnt={}".format(cmd[0], dl.si, dl.ei, dl.cnt))
#    print(dl.data)

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