from collections import deque

n = int(input())
q = deque()
for i in range(n):
    com = input().split()
    if com[0] == 'insert':
        q.appendleft(com[1])
    elif com[0] == 'delete':
        try:
            q.remove(com[1])
        except:
            pass
    elif com[0] == 'deleteFirst':
        q.popleft()
    else:
        q.pop()
print(" ".join(q)) from collections import deque n = int(input()) n int(input()) int input() input q = deque() q deque() deque for i in range(n):
    com = input().split()
    if com[0] == 'insert':
        q.appendleft(com[1])
    elif com[0] == 'delete':
        try:
            q.remove(com[1])
        except:
            pass
    elif com[0] == 'deleteFirst':
        q.popleft()
    else:
        q.pop() i range(n) range n com = input().split() com input().split() ().split () input split if com[0] == 'insert':
        q.appendleft(com[1])
    elif com[0] == 'delete':
        try:
            q.remove(com[1])
        except:
            pass
    elif com[0] == 'deleteFirst':
        q.popleft()
    else:
        q.pop() com[0] == 'insert' com[0] com 0 'insert' q.appendleft(com[1]) q.appendleft q appendleft com[1] com 1 elif com[0] == 'delete':
        try:
            q.remove(com[1])
        except:
            pass
     com[0] == 'delete' com[0] com 0 'delete' try:
            q.remove(com[1])
        except:
            pass
     except:
            pass
     q.remove(com[1]) q.remove q remove com[1] com 1 elif com[0] == 'deleteFirst':
        q.popleft()
     com[0] == 'deleteFirst' com[0] com 0 'deleteFirst' q.popleft() q.popleft q popleft q.pop() q.pop q pop print(" ".join(q)) print " ".join(q) " ".join " " join q com = input().split() input().split() com q = deque() deque() q n = int(input()) int(input()) n
from collections import deque

n = int(input())
q = deque()
for i in range(n):
    com = input().split()
    if com[0] == 'insert':
        q.appendleft(com[1])
    elif com[0] == 'delete':
        try:
            q.remove(com[1])
        except:
            pass
    elif com[0] == 'deleteFirst':
        q.popleft()
    else:
        q.pop()
print(" ".join(q))
