from collections import deque
n = int(raw_input())
R = deque()
for i in xrange(n):
    L = raw_input().split()
    order = L[0]
    value = 0
    if len(L) > 1:
        value = int(L[1])
    if order == 'insert':
        R.appendleft(value)
    if order == 'delete' and value in R:
        R.remove(value)
    if order == 'deleteFirst':
        R.popleft()
    if order == 'deleteLast':
        R.pop()
print ' '.join(map(str, R)) from collections import deque n = int(raw_input()) n int(raw_input()) int raw_input() raw_input R = deque() R deque() deque for i in xrange(n):
    L = raw_input().split()
    order = L[0]
    value = 0
    if len(L) > 1:
        value = int(L[1])
    if order == 'insert':
        R.appendleft(value)
    if order == 'delete' and value in R:
        R.remove(value)
    if order == 'deleteFirst':
        R.popleft()
    if order == 'deleteLast':
        R.pop() i xrange(n) xrange n L = raw_input().split() L raw_input().split() ().split () raw_input split order = L[0] order L[0] L 0 value = 0 value 0 if len(L) > 1:
        value = int(L[1])
     len(L) > 1 len(L) len L 1 value = int(L[1]) value int(L[1]) int L[1] L 1 if order == 'insert':
        R.appendleft(value)
     order == 'insert' order 'insert' R.appendleft(value) R.appendleft R appendleft value if order == 'delete' and value in R:
        R.remove(value)
     order == 'delete' and value in R order == 'delete' order 'delete' value in R value R R.remove(value) R.remove R remove value if order == 'deleteFirst':
        R.popleft()
     order == 'deleteFirst' order 'deleteFirst' R.popleft() R.popleft R popleft if order == 'deleteLast':
        R.pop() order == 'deleteLast' order 'deleteLast' R.pop() R.pop R pop print ' '.join(map(str, R)) ' '.join ' ' join map(str, R) map str R n = int(raw_input()) int(raw_input()) n R = deque() deque() R L = raw_input().split() raw_input().split() L value = int(L[1]) int(L[1]) value order = L[0] L[0] order value = 0 0 value
from collections import deque
n = int(raw_input())
R = deque()
for i in xrange(n):
    L = raw_input().split()
    order = L[0]
    value = 0
    if len(L) > 1:
        value = int(L[1])
    if order == 'insert':
        R.appendleft(value)
    if order == 'delete' and value in R:
        R.remove(value)
    if order == 'deleteFirst':
        R.popleft()
    if order == 'deleteLast':
        R.pop()
print ' '.join(map(str, R))