# coding=utf-8
from collections import deque
n = int(input())
deque = deque()

for i in range(n):
    inp = list(input().split())
    if inp[0] == 'deleteFirst':
        deque.popleft()
    elif inp[0] == 'deleteLast':
        deque.pop()
    elif inp[0] == 'insert':
        deque.appendleft(inp[1])
    else:
        if inp[1] in deque:
            deque.remove(inp[1])

print(*deque) from collections import deque n = int(input()) n int(input()) int input() input deque = deque() deque deque() deque for i in range(n):
    inp = list(input().split())
    if inp[0] == 'deleteFirst':
        deque.popleft()
    elif inp[0] == 'deleteLast':
        deque.pop()
    elif inp[0] == 'insert':
        deque.appendleft(inp[1])
    else:
        if inp[1] in deque:
            deque.remove(inp[1]) i range(n) range n inp = list(input().split()) inp list(input().split()) list input().split() ().split () input split if inp[0] == 'deleteFirst':
        deque.popleft()
    elif inp[0] == 'deleteLast':
        deque.pop()
    elif inp[0] == 'insert':
        deque.appendleft(inp[1])
    else:
        if inp[1] in deque:
            deque.remove(inp[1]) inp[0] == 'deleteFirst' inp[0] inp 0 'deleteFirst' deque.popleft() deque.popleft deque popleft elif inp[0] == 'deleteLast':
        deque.pop()
     inp[0] == 'deleteLast' inp[0] inp 0 'deleteLast' deque.pop() deque.pop deque pop elif inp[0] == 'insert':
        deque.appendleft(inp[1])
     inp[0] == 'insert' inp[0] inp 0 'insert' deque.appendleft(inp[1]) deque.appendleft deque appendleft inp[1] inp 1 if inp[1] in deque:
            deque.remove(inp[1]) inp[1] in deque inp[1] inp 1 deque deque.remove(inp[1]) deque.remove deque remove inp[1] inp 1 print(*deque) print *deque deque inp = list(input().split()) list(input().split()) inp deque = deque() deque() deque n = int(input()) int(input()) n
# coding=utf-8
from collections import deque
n = int(input())
deque = deque()

for i in range(n):
    inp = list(input().split())
    if inp[0] == 'deleteFirst':
        deque.popleft()
    elif inp[0] == 'deleteLast':
        deque.pop()
    elif inp[0] == 'insert':
        deque.appendleft(inp[1])
    else:
        if inp[1] in deque:
            deque.remove(inp[1])

print(*deque)