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