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

from collections import deque

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

for i in range(N):
    lst = input().split()
    command = lst[0]
    if command == 'insert':
        q.appendleft(lst[1])
    elif command == 'delete':
        try:
            q.remove(lst[1])
        except Exception:
            pass
    elif command == 'deleteFirst':
        q.popleft()
    elif command == 'deleteLast':
        q.pop()

print(*q) 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':
        q.appendleft(lst[1])
    elif command == 'delete':
        try:
            q.remove(lst[1])
        except Exception:
            pass
    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':
        q.appendleft(lst[1])
    elif command == 'delete':
        try:
            q.remove(lst[1])
        except Exception:
            pass
    elif command == 'deleteFirst':
        q.popleft()
    elif command == 'deleteLast':
        q.pop() command == 'insert' command 'insert' q.appendleft(lst[1]) q.appendleft q appendleft lst[1] lst 1 elif command == 'delete':
        try:
            q.remove(lst[1])
        except Exception:
            pass
     command == 'delete' command 'delete' try:
            q.remove(lst[1])
        except Exception:
            pass
     except Exception:
            pass
     q.remove(lst[1]) q.remove q remove lst[1] lst 1 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(*q) print *q q q = deque() deque() q N = int(input()) int(input()) N command = lst[0] lst[0] command lst = input().split() input().split() lst
# -*- coding: utf-8 -*-

from collections import deque

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

for i in range(N):
    lst = input().split()
    command = lst[0]
    if command == 'insert':
        q.appendleft(lst[1])
    elif command == 'delete':
        try:
            q.remove(lst[1])
        except Exception:
            pass
    elif command == 'deleteFirst':
        q.popleft()
    elif command == 'deleteLast':
        q.pop()

print(*q)