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

import sys
import os
from collections import deque


N = int(sys.stdin.readline())
q = deque()

lines = sys.stdin.readlines()
for s in lines:
    lst = s.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) import sys sys import os os from collections import deque N = int(sys.stdin.readline()) N int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline q = deque() q deque() deque lines = sys.stdin.readlines() lines sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines for s in lines:
    lst = s.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() s lines lst = s.split() lst s.split() s.split s 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 N = int(sys.stdin.readline()) int(sys.stdin.readline()) N lst = s.split() s.split() lst lines = sys.stdin.readlines() sys.stdin.readlines() lines command = lst[0] lst[0] command q = deque() deque() q
# -*- coding: utf-8 -*-

import sys
import os
from collections import deque


N = int(sys.stdin.readline())
q = deque()

lines = sys.stdin.readlines()
for s in lines:
    lst = s.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)