from collections import deque

n = int(input())
d = deque()
for _i in range(n):
    line = input().split()
    order = line[0]
    if order in ('insert', 'delete'):
        key = line[1]
    if order == 'insert':
        d.appendleft(key)
    elif order == 'delete':
        try:
            d.remove(key)
        except ValueError:
            pass
    elif order == 'deleteFirst':
        d.popleft()
    elif order == 'deleteLast':
        d.pop()
    else:
        raise ValueError('Invalid order: {order}')

print(' '.join(d))
 from collections import deque n = int(input()) n int(input()) int input() input d = deque() d deque() deque for _i in range(n):
    line = input().split()
    order = line[0]
    if order in ('insert', 'delete'):
        key = line[1]
    if order == 'insert':
        d.appendleft(key)
    elif order == 'delete':
        try:
            d.remove(key)
        except ValueError:
            pass
    elif order == 'deleteFirst':
        d.popleft()
    elif order == 'deleteLast':
        d.pop()
    else:
        raise ValueError('Invalid order: {order}') _i range(n) range n line = input().split() line input().split() ().split () input split order = line[0] order line[0] line 0 if order in ('insert', 'delete'):
        key = line[1]
     order in ('insert', 'delete') order ('insert', 'delete') 'insert' 'delete' key = line[1] key line[1] line 1 if order == 'insert':
        d.appendleft(key)
    elif order == 'delete':
        try:
            d.remove(key)
        except ValueError:
            pass
    elif order == 'deleteFirst':
        d.popleft()
    elif order == 'deleteLast':
        d.pop()
    else:
        raise ValueError('Invalid order: {order}') order == 'insert' order 'insert' d.appendleft(key) d.appendleft d appendleft key elif order == 'delete':
        try:
            d.remove(key)
        except ValueError:
            pass
     order == 'delete' order 'delete' try:
            d.remove(key)
        except ValueError:
            pass
     except ValueError:
            pass
     d.remove(key) d.remove d remove key elif order == 'deleteFirst':
        d.popleft()
     order == 'deleteFirst' order 'deleteFirst' d.popleft() d.popleft d popleft elif order == 'deleteLast':
        d.pop()
     order == 'deleteLast' order 'deleteLast' d.pop() d.pop d pop raise ValueError('Invalid order: {order}') ValueError('Invalid order: {order}') ValueError 'Invalid order: {order}' print(' '.join(d)) print ' '.join(d) ' '.join ' ' join d n = int(input()) int(input()) n line = input().split() input().split() line order = line[0] line[0] order key = line[1] line[1] key d = deque() deque() d
from collections import deque

n = int(input())
d = deque()
for _i in range(n):
    line = input().split()
    order = line[0]
    if order in ('insert', 'delete'):
        key = line[1]
    if order == 'insert':
        d.appendleft(key)
    elif order == 'delete':
        try:
            d.remove(key)
        except ValueError:
            pass
    elif order == 'deleteFirst':
        d.popleft()
    elif order == 'deleteLast':
        d.pop()
    else:
        raise ValueError('Invalid order: {order}')

print(' '.join(d))

