import sys
from collections import deque
N = int(sys.stdin.readline())
lines = sys.stdin.readlines()

l = deque()
for i in range(N):
    command = lines[i].split()
    if command[0] == 'deleteFirst':
        l.popleft()
    elif command[0] == 'deleteLast':
        l.pop()
    elif command[0] == 'insert':
        l.appendleft(command[1])
    else:
        if command[1] in l:
            l.remove(command[1])
            
print(' '.join(map(str, l)))
     import sys sys from collections import deque N = int(sys.stdin.readline()) N int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline lines = sys.stdin.readlines() lines sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines l = deque() l deque() deque for i in range(N):
    command = lines[i].split()
    if command[0] == 'deleteFirst':
        l.popleft()
    elif command[0] == 'deleteLast':
        l.pop()
    elif command[0] == 'insert':
        l.appendleft(command[1])
    else:
        if command[1] in l:
            l.remove(command[1])
             i range(N) range N command = lines[i].split() command lines[i].split() [i].split [i] lines i split if command[0] == 'deleteFirst':
        l.popleft()
    elif command[0] == 'deleteLast':
        l.pop()
    elif command[0] == 'insert':
        l.appendleft(command[1])
    else:
        if command[1] in l:
            l.remove(command[1])
             command[0] == 'deleteFirst' command[0] command 0 'deleteFirst' l.popleft() l.popleft l popleft elif command[0] == 'deleteLast':
        l.pop()
     command[0] == 'deleteLast' command[0] command 0 'deleteLast' l.pop() l.pop l pop elif command[0] == 'insert':
        l.appendleft(command[1])
     command[0] == 'insert' command[0] command 0 'insert' l.appendleft(command[1]) l.appendleft l appendleft command[1] command 1 if command[1] in l:
            l.remove(command[1])
             command[1] in l command[1] command 1 l l.remove(command[1]) l.remove l remove command[1] command 1 print(' '.join(map(str, l))) print ' '.join(map(str, l)) ' '.join ' ' join map(str, l) map str l l = deque() deque() l N = int(sys.stdin.readline()) int(sys.stdin.readline()) N lines = sys.stdin.readlines() sys.stdin.readlines() lines command = lines[i].split() lines[i].split() command
import sys
from collections import deque
N = int(sys.stdin.readline())
lines = sys.stdin.readlines()

l = deque()
for i in range(N):
    command = lines[i].split()
    if command[0] == 'deleteFirst':
        l.popleft()
    elif command[0] == 'deleteLast':
        l.pop()
    elif command[0] == 'insert':
        l.appendleft(command[1])
    else:
        if command[1] in l:
            l.remove(command[1])
            
print(' '.join(map(str, l)))
    
