from collections import deque

n = int(input())

dlist = deque()

for i in range(n):
    arr = input().split()
    cmd = ''
    key = 0
    cmd = arr[0]
    if len(arr) > 1:
        key = arr[1]
    if cmd == 'insert':
        dlist.appendleft(key)
    elif cmd == 'delete':
        try:
            dlist.remove(key)
        except:
            continue
    elif cmd == 'deleteFirst':
        dlist.popleft()
    elif cmd == 'deleteLast':
        dlist.pop()

print(' '.join(dlist))

 from collections import deque n = int(input()) n int(input()) int input() input dlist = deque() dlist deque() deque for i in range(n):
    arr = input().split()
    cmd = ''
    key = 0
    cmd = arr[0]
    if len(arr) > 1:
        key = arr[1]
    if cmd == 'insert':
        dlist.appendleft(key)
    elif cmd == 'delete':
        try:
            dlist.remove(key)
        except:
            continue
    elif cmd == 'deleteFirst':
        dlist.popleft()
    elif cmd == 'deleteLast':
        dlist.pop() i range(n) range n arr = input().split() arr input().split() ().split () input split cmd = '' cmd '' key = 0 key 0 cmd = arr[0] cmd arr[0] arr 0 if len(arr) > 1:
        key = arr[1]
     len(arr) > 1 len(arr) len arr 1 key = arr[1] key arr[1] arr 1 if cmd == 'insert':
        dlist.appendleft(key)
    elif cmd == 'delete':
        try:
            dlist.remove(key)
        except:
            continue
    elif cmd == 'deleteFirst':
        dlist.popleft()
    elif cmd == 'deleteLast':
        dlist.pop() cmd == 'insert' cmd 'insert' dlist.appendleft(key) dlist.appendleft dlist appendleft key elif cmd == 'delete':
        try:
            dlist.remove(key)
        except:
            continue
     cmd == 'delete' cmd 'delete' try:
            dlist.remove(key)
        except:
            continue
     except:
            continue
     continue dlist.remove(key) dlist.remove dlist remove key elif cmd == 'deleteFirst':
        dlist.popleft()
     cmd == 'deleteFirst' cmd 'deleteFirst' dlist.popleft() dlist.popleft dlist popleft elif cmd == 'deleteLast':
        dlist.pop() cmd == 'deleteLast' cmd 'deleteLast' dlist.pop() dlist.pop dlist pop print(' '.join(dlist)) print ' '.join(dlist) ' '.join ' ' join dlist dlist = deque() deque() dlist key = arr[1] arr[1] key arr = input().split() input().split() arr key = 0 0 key cmd = arr[0] arr[0] cmd n = int(input()) int(input()) n cmd = '' '' cmd
from collections import deque

n = int(input())

dlist = deque()

for i in range(n):
    arr = input().split()
    cmd = ''
    key = 0
    cmd = arr[0]
    if len(arr) > 1:
        key = arr[1]
    if cmd == 'insert':
        dlist.appendleft(key)
    elif cmd == 'delete':
        try:
            dlist.remove(key)
        except:
            continue
    elif cmd == 'deleteFirst':
        dlist.popleft()
    elif cmd == 'deleteLast':
        dlist.pop()

print(' '.join(dlist))


