import sys
res = dict()
dll = [None] * 2000000
left = 0
right = 0
n = int(input())
for inpt in sys.stdin.read().splitlines():
    i = inpt.split()
    if i[0] == "insert":
        x = int(i[1])
        dll[left] = x
        if(x in res):
            res[x].add(left)
        else:
            res[x] = set([left])
        left += 1
    if i[0] == "delete":
        x = int(i[1])
        if(x in res):
            ind = max(res[x])
            dll[ind] = None
            res[x].remove(ind)
            if(len(res[x]) == 0):
                del res[x]
            if(ind == (left - 1)):
                left = ind
            if(ind == right):
                right += 1
    if i[0] == "deleteFirst":
        left -= 1
        x = dll[left]
        res[x].remove(left)
        if(len(res[x]) == 0):
            del res[x]
        dll[left] = None
    if i[0] == "deleteLast":
        right += 1
    # print(dll[right:left])
ret = []
for x in dll[right:left]:
    if(x is not None):
        ret.append(str(x))
ret.reverse()
print(" ".join(ret)) import sys sys res = dict() res dict() dict dll = [None] * 2000000 dll [None] * 2000000 [None] None 2000000 left = 0 left 0 right = 0 right 0 n = int(input()) n int(input()) int input() input for inpt in sys.stdin.read().splitlines():
    i = inpt.split()
    if i[0] == "insert":
        x = int(i[1])
        dll[left] = x
        if(x in res):
            res[x].add(left)
        else:
            res[x] = set([left])
        left += 1
    if i[0] == "delete":
        x = int(i[1])
        if(x in res):
            ind = max(res[x])
            dll[ind] = None
            res[x].remove(ind)
            if(len(res[x]) == 0):
                del res[x]
            if(ind == (left - 1)):
                left = ind
            if(ind == right):
                right += 1
    if i[0] == "deleteFirst":
        left -= 1
        x = dll[left]
        res[x].remove(left)
        if(len(res[x]) == 0):
            del res[x]
        dll[left] = None
    if i[0] == "deleteLast":
        right += 1
    # print(dll[right:left]) inpt sys.stdin.read().splitlines() sys.stdin.read().splitlines sys.stdin.read() sys.stdin.read sys.stdin sys stdin read splitlines i = inpt.split() i inpt.split() inpt.split inpt split if i[0] == "insert":
        x = int(i[1])
        dll[left] = x
        if(x in res):
            res[x].add(left)
        else:
            res[x] = set([left])
        left += 1
     i[0] == "insert" i[0] i 0 "insert" x = int(i[1]) x int(i[1]) int i[1] i 1 dll[left] = x dll[left] dll left x if(x in res):
            res[x].add(left)
        else:
            res[x] = set([left])
         x in res x res res[x].add(left) [x].add [x] res x add left res[x] = set([left]) res[x] res x set([left]) set [left] left left += 1 left 1 if i[0] == "delete":
        x = int(i[1])
        if(x in res):
            ind = max(res[x])
            dll[ind] = None
            res[x].remove(ind)
            if(len(res[x]) == 0):
                del res[x]
            if(ind == (left - 1)):
                left = ind
            if(ind == right):
                right += 1
     i[0] == "delete" i[0] i 0 "delete" x = int(i[1]) x int(i[1]) int i[1] i 1 if(x in res):
            ind = max(res[x])
            dll[ind] = None
            res[x].remove(ind)
            if(len(res[x]) == 0):
                del res[x]
            if(ind == (left - 1)):
                left = ind
            if(ind == right):
                right += 1
     x in res x res ind = max(res[x]) ind max(res[x]) max res[x] res x dll[ind] = None dll[ind] dll ind None res[x].remove(ind) [x].remove [x] res x remove ind if(len(res[x]) == 0):
                del res[x]
             len(res[x]) == 0 len(res[x]) len res[x] res x 0 del res[x] res[x] res x if(ind == (left - 1)):
                left = ind
             ind == (left - 1) ind left - 1 left 1 left = ind left ind if(ind == right):
                right += 1
     ind == right ind right right += 1 right 1 if i[0] == "deleteFirst":
        left -= 1
        x = dll[left]
        res[x].remove(left)
        if(len(res[x]) == 0):
            del res[x]
        dll[left] = None
     i[0] == "deleteFirst" i[0] i 0 "deleteFirst" left -= 1 left 1 x = dll[left] x dll[left] dll left res[x].remove(left) [x].remove [x] res x remove left if(len(res[x]) == 0):
            del res[x]
         len(res[x]) == 0 len(res[x]) len res[x] res x 0 del res[x] res[x] res x dll[left] = None dll[left] dll left None if i[0] == "deleteLast":
        right += 1
    # print(dll[right:left]) i[0] == "deleteLast" i[0] i 0 "deleteLast" right += 1 right 1 ret = [] ret [] for x in dll[right:left]:
    if(x is not None):
        ret.append(str(x)) x dll[right:left] dll right:left right left if(x is not None):
        ret.append(str(x)) x is not None x None ret.append(str(x)) ret.append ret append str(x) str x ret.reverse() ret.reverse ret reverse print(" ".join(ret)) print " ".join(ret) " ".join " " join ret left = ind ind left ret = [] [] ret i = inpt.split() inpt.split() i left += 1 1 left ind = max(res[x]) max(res[x]) ind right += 1 1 right left -= 1 1 left left = 0 0 left x = int(i[1]) int(i[1]) x x = int(i[1]) int(i[1]) x n = int(input()) int(input()) n right = 0 0 right x = dll[left] dll[left] x dll = [None] * 2000000 [None] * 2000000 dll res = dict() dict() res right += 1 1 right
import sys
res = dict()
dll = [None] * 2000000
left = 0
right = 0
n = int(input())
for inpt in sys.stdin.read().splitlines():
    i = inpt.split()
    if i[0] == "insert":
        x = int(i[1])
        dll[left] = x
        if(x in res):
            res[x].add(left)
        else:
            res[x] = set([left])
        left += 1
    if i[0] == "delete":
        x = int(i[1])
        if(x in res):
            ind = max(res[x])
            dll[ind] = None
            res[x].remove(ind)
            if(len(res[x]) == 0):
                del res[x]
            if(ind == (left - 1)):
                left = ind
            if(ind == right):
                right += 1
    if i[0] == "deleteFirst":
        left -= 1
        x = dll[left]
        res[x].remove(left)
        if(len(res[x]) == 0):
            del res[x]
        dll[left] = None
    if i[0] == "deleteLast":
        right += 1
    # print(dll[right:left])
ret = []
for x in dll[right:left]:
    if(x is not None):
        ret.append(str(x))
ret.reverse()
print(" ".join(ret))