from collections import deque

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

n = int(input())
dll = deque()
for i in range(n):
    command = input().split()
    if command[0] == 'insert':
        dll.appendleft(command[1])
    elif command[0] == 'delete':
        try:
            dll.remove(command[1])
        except:
            pass
    elif command[0] == 'deleteFirst':
        dll.popleft()
    else:
        dll.pop()
print(*dll)