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

Q = deque()
for i in range(n):
    command = lines[i].split()
    if command[0] == 'insert':
        Q.appendleft(command[1])
    elif command[0] == 'delete':
        try:
            Q.remove(command[1])
        except:
            pass
    elif command[0] == 'deleteFirst':
        Q.popleft()
    elif command[0] == 'deleteLast':
        Q.pop()
print(' '.join(Q)) 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 Q = deque() Q deque() deque for i in range(n):
    command = lines[i].split()
    if command[0] == 'insert':
        Q.appendleft(command[1])
    elif command[0] == 'delete':
        try:
            Q.remove(command[1])
        except:
            pass
    elif command[0] == 'deleteFirst':
        Q.popleft()
    elif command[0] == 'deleteLast':
        Q.pop() i range(n) range n command = lines[i].split() command lines[i].split() [i].split [i] lines i split if command[0] == 'insert':
        Q.appendleft(command[1])
    elif command[0] == 'delete':
        try:
            Q.remove(command[1])
        except:
            pass
    elif command[0] == 'deleteFirst':
        Q.popleft()
    elif command[0] == 'deleteLast':
        Q.pop() command[0] == 'insert' command[0] command 0 'insert' Q.appendleft(command[1]) Q.appendleft Q appendleft command[1] command 1 elif command[0] == 'delete':
        try:
            Q.remove(command[1])
        except:
            pass
     command[0] == 'delete' command[0] command 0 'delete' try:
            Q.remove(command[1])
        except:
            pass
     except:
            pass
     Q.remove(command[1]) Q.remove Q remove command[1] command 1 elif command[0] == 'deleteFirst':
        Q.popleft()
     command[0] == 'deleteFirst' command[0] command 0 'deleteFirst' Q.popleft() Q.popleft Q popleft elif command[0] == 'deleteLast':
        Q.pop() command[0] == 'deleteLast' command[0] command 0 'deleteLast' Q.pop() Q.pop Q pop print(' '.join(Q)) print ' '.join(Q) ' '.join ' ' join Q command = lines[i].split() lines[i].split() command lines = sys.stdin.readlines() sys.stdin.readlines() lines Q = deque() deque() Q n = int(sys.stdin.readline()) int(sys.stdin.readline()) n
import sys
from collections import deque
n = int(sys.stdin.readline())
lines = sys.stdin.readlines()

Q = deque()
for i in range(n):
    command = lines[i].split()
    if command[0] == 'insert':
        Q.appendleft(command[1])
    elif command[0] == 'delete':
        try:
            Q.remove(command[1])
        except:
            pass
    elif command[0] == 'deleteFirst':
        Q.popleft()
    elif command[0] == 'deleteLast':
        Q.pop()
print(' '.join(Q))