# -*- coding: utf-8 -*-

import sys
import os
from collections import deque


N = int(input())
q = deque()

for i in range(N):
    lst = input().split()
    command = lst[0]
    if command == 'insert':
        v = int(lst[1])
        q.appendleft(v)
    elif command == 'delete':
        v = int(lst[1])
        if v in q:
            q.remove(v)
    elif command == 'deleteFirst':
        q.popleft()
    elif command == 'deleteLast':
        q.pop()
print(*list(q)) import sys sys import os os from collections import deque N = int(input()) N int(input()) int input() input q = deque() q deque() deque for i in range(N):
    lst = input().split()
    command = lst[0]
    if command == 'insert':
        v = int(lst[1])
        q.appendleft(v)
    elif command == 'delete':
        v = int(lst[1])
        if v in q:
            q.remove(v)
    elif command == 'deleteFirst':
        q.popleft()
    elif command == 'deleteLast':
        q.pop() i range(N) range N lst = input().split() lst input().split() ().split () input split command = lst[0] command lst[0] lst 0 if command == 'insert':
        v = int(lst[1])
        q.appendleft(v)
    elif command == 'delete':
        v = int(lst[1])
        if v in q:
            q.remove(v)
    elif command == 'deleteFirst':
        q.popleft()
    elif command == 'deleteLast':
        q.pop() command == 'insert' command 'insert' v = int(lst[1]) v int(lst[1]) int lst[1] lst 1 q.appendleft(v) q.appendleft q appendleft v elif command == 'delete':
        v = int(lst[1])
        if v in q:
            q.remove(v)
     command == 'delete' command 'delete' v = int(lst[1]) v int(lst[1]) int lst[1] lst 1 if v in q:
            q.remove(v)
     v in q v q q.remove(v) q.remove q remove v elif command == 'deleteFirst':
        q.popleft()
     command == 'deleteFirst' command 'deleteFirst' q.popleft() q.popleft q popleft elif command == 'deleteLast':
        q.pop() command == 'deleteLast' command 'deleteLast' q.pop() q.pop q pop print(*list(q)) print *list(q) list(q) list q lst = input().split() input().split() lst command = lst[0] lst[0] command N = int(input()) int(input()) N q = deque() deque() q v = int(lst[1]) int(lst[1]) v v = int(lst[1]) int(lst[1]) v
# -*- coding: utf-8 -*-

import sys
import os
from collections import deque


N = int(input())
q = deque()

for i in range(N):
    lst = input().split()
    command = lst[0]
    if command == 'insert':
        v = int(lst[1])
        q.appendleft(v)
    elif command == 'delete':
        v = int(lst[1])
        if v in q:
            q.remove(v)
    elif command == 'deleteFirst':
        q.popleft()
    elif command == 'deleteLast':
        q.pop()
print(*list(q))