import sys
from collections import deque


input = sys.stdin.readline

n = int(input())
orders = []
for i in range(n):
    orders.append(input().strip())

#orders = ["insert 5","insert 2","insert 3","insert 1","delete 3","insert 6","delete 5"]
#orders = ["insert 5","insert 2","insert 3","insert 1","delete 3","insert 6","delete 5","deleteFirst","deleteLast"]

data = deque()
for d in orders:
    if " " in d:
        order, value = d.split(" ")
    else:
        order = d

    if order == "insert":
        data.appendleft(value)
    elif order == "delete":
        try:
            data.remove(value)
        except ValueError:
            pass
    elif order == "deleteFirst":
        data.popleft()
    elif order == "deleteLast":
        data.pop()
    else:
        print('Unknown order')

# print result
print(" ".join(data))

 import sys sys from collections import deque input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n = int(input()) n int(input()) int input() input orders = [] orders [] for i in range(n):
    orders.append(input().strip())

#orders = ["insert 5","insert 2","insert 3","insert 1","delete 3","insert 6","delete 5"]
#orders = ["insert 5","insert 2","insert 3","insert 1","delete 3","insert 6","delete 5","deleteFirst","deleteLast"] i range(n) range n orders.append(input().strip()) orders.append orders append input().strip() ().strip () input strip data = deque() data deque() deque for d in orders:
    if " " in d:
        order, value = d.split(" ")
    else:
        order = d

    if order == "insert":
        data.appendleft(value)
    elif order == "delete":
        try:
            data.remove(value)
        except ValueError:
            pass
    elif order == "deleteFirst":
        data.popleft()
    elif order == "deleteLast":
        data.pop()
    else:
        print('Unknown order')

# print result d orders if " " in d:
        order, value = d.split(" ")
    else:
        order = d

     " " in d " " d order, value = d.split(" ") order d.split(" ") d.split d split " " value order = d order d if order == "insert":
        data.appendleft(value)
    elif order == "delete":
        try:
            data.remove(value)
        except ValueError:
            pass
    elif order == "deleteFirst":
        data.popleft()
    elif order == "deleteLast":
        data.pop()
    else:
        print('Unknown order')

# print result order == "insert" order "insert" data.appendleft(value) data.appendleft data appendleft value elif order == "delete":
        try:
            data.remove(value)
        except ValueError:
            pass
     order == "delete" order "delete" try:
            data.remove(value)
        except ValueError:
            pass
     except ValueError:
            pass
     data.remove(value) data.remove data remove value elif order == "deleteFirst":
        data.popleft()
     order == "deleteFirst" order "deleteFirst" data.popleft() data.popleft data popleft elif order == "deleteLast":
        data.pop()
     order == "deleteLast" order "deleteLast" data.pop() data.pop data pop print('Unknown order') print 'Unknown order' print(" ".join(data)) print " ".join(data) " ".join " " join data orders = [] [] orders order = d d order order, value = d.split(" ") d.split(" ") order n = int(input()) int(input()) n value = d.split(" ") d.split(" ") value input = sys.stdin.readline sys.stdin.readline input data = deque() deque() data
import sys
from collections import deque


input = sys.stdin.readline

n = int(input())
orders = []
for i in range(n):
    orders.append(input().strip())

#orders = ["insert 5","insert 2","insert 3","insert 1","delete 3","insert 6","delete 5"]
#orders = ["insert 5","insert 2","insert 3","insert 1","delete 3","insert 6","delete 5","deleteFirst","deleteLast"]

data = deque()
for d in orders:
    if " " in d:
        order, value = d.split(" ")
    else:
        order = d

    if order == "insert":
        data.appendleft(value)
    elif order == "delete":
        try:
            data.remove(value)
        except ValueError:
            pass
    elif order == "deleteFirst":
        data.popleft()
    elif order == "deleteLast":
        data.pop()
    else:
        print('Unknown order')

# print result
print(" ".join(data))


