from collections import deque

n = int(input())
d = deque()

for i in range(n):
    c = input()
    if ' ' in c:
        c, num = c.split()
        if c == 'insert':
            d.appendleft(num)
        elif c == 'delete' and num in d:
            d.remove(num)
    else:
        if c == 'deleteFirst' and d:
            d.popleft()
        elif c == 'deleteLast' and d:
            d.pop()

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):
    c = input()
    if ' ' in c:
        c, num = c.split()
        if c == 'insert':
            d.appendleft(num)
        elif c == 'delete' and num in d:
            d.remove(num)
    else:
        if c == 'deleteFirst' and d:
            d.popleft()
        elif c == 'deleteLast' and d:
            d.pop() i range(n) range n c = input() c input() input if ' ' in c:
        c, num = c.split()
        if c == 'insert':
            d.appendleft(num)
        elif c == 'delete' and num in d:
            d.remove(num)
    else:
        if c == 'deleteFirst' and d:
            d.popleft()
        elif c == 'deleteLast' and d:
            d.pop() ' ' in c ' ' c c, num = c.split() c c.split() c.split c split num if c == 'insert':
            d.appendleft(num)
        elif c == 'delete' and num in d:
            d.remove(num)
     c == 'insert' c 'insert' d.appendleft(num) d.appendleft d appendleft num elif c == 'delete' and num in d:
            d.remove(num)
     c == 'delete' and num in d c == 'delete' c 'delete' num in d num d d.remove(num) d.remove d remove num if c == 'deleteFirst' and d:
            d.popleft()
        elif c == 'deleteLast' and d:
            d.pop() c == 'deleteFirst' and d c == 'deleteFirst' c 'deleteFirst' d d.popleft() d.popleft d popleft elif c == 'deleteLast' and d:
            d.pop() c == 'deleteLast' and d c == 'deleteLast' c 'deleteLast' d d.pop() d.pop d pop print(' '.join(d)) print ' '.join(d) ' '.join ' ' join d n = int(input()) int(input()) n c = input() input() c d = deque() deque() d c, num = c.split() c.split() c num = c.split() c.split() num
from collections import deque

n = int(input())
d = deque()

for i in range(n):
    c = input()
    if ' ' in c:
        c, num = c.split()
        if c == 'insert':
            d.appendleft(num)
        elif c == 'delete' and num in d:
            d.remove(num)
    else:
        if c == 'deleteFirst' and d:
            d.popleft()
        elif c == 'deleteLast' and d:
            d.pop()

print(' '.join(d))
