#  deque

import collections
import sys
deque = collections.deque([])

n = int(input())
for i in range(n):
    query = sys.stdin.readline().split()
    if query[0] == "insert":
        deque.appendleft(int(query[1]))
    elif query[0] == "deleteFirst":
        deque.popleft()
    elif query[0] == "deleteLast":
        deque.pop()
    elif query[0] == "delete":
        try:
            deque.index(int(query[1]))
        except:
            pass
        else:
            deque.remove(int(query[1]))

print(*deque) import collections collections import sys sys deque = collections.deque([]) deque collections.deque([]) collections.deque collections deque [] n = int(input()) n int(input()) int input() input for i in range(n):
    query = sys.stdin.readline().split()
    if query[0] == "insert":
        deque.appendleft(int(query[1]))
    elif query[0] == "deleteFirst":
        deque.popleft()
    elif query[0] == "deleteLast":
        deque.pop()
    elif query[0] == "delete":
        try:
            deque.index(int(query[1]))
        except:
            pass
        else:
            deque.remove(int(query[1])) i range(n) range n query = sys.stdin.readline().split() query sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split if query[0] == "insert":
        deque.appendleft(int(query[1]))
    elif query[0] == "deleteFirst":
        deque.popleft()
    elif query[0] == "deleteLast":
        deque.pop()
    elif query[0] == "delete":
        try:
            deque.index(int(query[1]))
        except:
            pass
        else:
            deque.remove(int(query[1])) query[0] == "insert" query[0] query 0 "insert" deque.appendleft(int(query[1])) deque.appendleft deque appendleft int(query[1]) int query[1] query 1 elif query[0] == "deleteFirst":
        deque.popleft()
     query[0] == "deleteFirst" query[0] query 0 "deleteFirst" deque.popleft() deque.popleft deque popleft elif query[0] == "deleteLast":
        deque.pop()
     query[0] == "deleteLast" query[0] query 0 "deleteLast" deque.pop() deque.pop deque pop elif query[0] == "delete":
        try:
            deque.index(int(query[1]))
        except:
            pass
        else:
            deque.remove(int(query[1])) query[0] == "delete" query[0] query 0 "delete" try:
            deque.index(int(query[1]))
        except:
            pass
        else:
            deque.remove(int(query[1])) except:
            pass
         deque.index(int(query[1])) deque.index deque index int(query[1]) int query[1] query 1 deque.remove(int(query[1])) deque.remove deque remove int(query[1]) int query[1] query 1 print(*deque) print *deque deque deque = collections.deque([]) collections.deque([]) deque n = int(input()) int(input()) n query = sys.stdin.readline().split() sys.stdin.readline().split() query
#  deque

import collections
import sys
deque = collections.deque([])

n = int(input())
for i in range(n):
    query = sys.stdin.readline().split()
    if query[0] == "insert":
        deque.appendleft(int(query[1]))
    elif query[0] == "deleteFirst":
        deque.popleft()
    elif query[0] == "deleteLast":
        deque.pop()
    elif query[0] == "delete":
        try:
            deque.index(int(query[1]))
        except:
            pass
        else:
            deque.remove(int(query[1]))

print(*deque)
