from collections import deque
lis = deque()
num = int(input())
for _ in range(num):
  command = input().split()
  if command[0]=='deleteFirst':
    lis.popleft()
  elif command[0]=='deleteLast':
    lis.pop()
  elif command[0]=='insert':
    lis.insert(0, command[1])
  elif command[0]=='delete':
    try:
        lis.remove(command[1])
    except:
        pass
print(' '.join(lis)) from collections import deque lis = deque() lis deque() deque num = int(input()) num int(input()) int input() input for _ in range(num):
  command = input().split()
  if command[0]=='deleteFirst':
    lis.popleft()
  elif command[0]=='deleteLast':
    lis.pop()
  elif command[0]=='insert':
    lis.insert(0, command[1])
  elif command[0]=='delete':
    try:
        lis.remove(command[1])
    except:
        pass _ range(num) range num command = input().split() command input().split() ().split () input split if command[0]=='deleteFirst':
    lis.popleft()
  elif command[0]=='deleteLast':
    lis.pop()
  elif command[0]=='insert':
    lis.insert(0, command[1])
  elif command[0]=='delete':
    try:
        lis.remove(command[1])
    except:
        pass command[0]=='deleteFirst' command[0] command 0 'deleteFirst' lis.popleft() lis.popleft lis popleft elif command[0]=='deleteLast':
    lis.pop()
   command[0]=='deleteLast' command[0] command 0 'deleteLast' lis.pop() lis.pop lis pop elif command[0]=='insert':
    lis.insert(0, command[1])
   command[0]=='insert' command[0] command 0 'insert' lis.insert(0, command[1]) lis.insert lis insert 0 command[1] command 1 elif command[0]=='delete':
    try:
        lis.remove(command[1])
    except:
        pass command[0]=='delete' command[0] command 0 'delete' try:
        lis.remove(command[1])
    except:
        pass except:
        pass lis.remove(command[1]) lis.remove lis remove command[1] command 1 print(' '.join(lis)) print ' '.join(lis) ' '.join ' ' join lis num = int(input()) int(input()) num command = input().split() input().split() command lis = deque() deque() lis
from collections import deque
lis = deque()
num = int(input())
for _ in range(num):
  command = input().split()
  if command[0]=='deleteFirst':
    lis.popleft()
  elif command[0]=='deleteLast':
    lis.pop()
  elif command[0]=='insert':
    lis.insert(0, command[1])
  elif command[0]=='delete':
    try:
        lis.remove(command[1])
    except:
        pass
print(' '.join(lis))
