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