from sys import stdin
from collections import deque
input = stdin.readline

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

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