# Original solution
#!/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:
            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()
#    print(cmd)
#    print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#    print(dl.data)

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

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

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

# ?????????
num = int(input().strip())
dl = []

for i in range(num):
    cmd = list(input().strip().split())
    if cmd[0] == "insert":
        dl.insert(0,cmd[1])
    elif cmd[0] == "delete":
        try:
            dl.remove(cmd[1])
        except ValueError:
            i = 1
    elif cmd[0] == "deleteFirst":
        dl.pop(0)
    elif cmd[0] == "deleteLast":
        dl.pop()

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