from collections import deque
from sys import stdin
n = int(input())
L = deque()
for _ in range(n):
    com = list(map(str, stdin.readline().split()))
    if com[0] == 'insert':
        i = int(com[1])
        L.appendleft(i)
    elif com[0] == 'delete':
        i = int(com[1])
        try:
            L.remove(i)
        except ValueError:
            continue
    elif com[0] == 'deleteFirst':
        L.popleft()
    elif com[0] == 'deleteLast':
        L.pop()
for i in range(len(L)):
    if i == len(L) - 1:
        print(L[i])
    else:
        print(L[i], end=' ') from collections import deque from sys import stdin n = int(input()) n int(input()) int input() input L = deque() L deque() deque for _ in range(n):
    com = list(map(str, stdin.readline().split()))
    if com[0] == 'insert':
        i = int(com[1])
        L.appendleft(i)
    elif com[0] == 'delete':
        i = int(com[1])
        try:
            L.remove(i)
        except ValueError:
            continue
    elif com[0] == 'deleteFirst':
        L.popleft()
    elif com[0] == 'deleteLast':
        L.pop() _ range(n) range n com = list(map(str, stdin.readline().split())) com list(map(str, stdin.readline().split())) list map(str, stdin.readline().split()) map str stdin.readline().split() stdin.readline().split stdin.readline() stdin.readline stdin readline split if com[0] == 'insert':
        i = int(com[1])
        L.appendleft(i)
    elif com[0] == 'delete':
        i = int(com[1])
        try:
            L.remove(i)
        except ValueError:
            continue
    elif com[0] == 'deleteFirst':
        L.popleft()
    elif com[0] == 'deleteLast':
        L.pop() com[0] == 'insert' com[0] com 0 'insert' i = int(com[1]) i int(com[1]) int com[1] com 1 L.appendleft(i) L.appendleft L appendleft i elif com[0] == 'delete':
        i = int(com[1])
        try:
            L.remove(i)
        except ValueError:
            continue
     com[0] == 'delete' com[0] com 0 'delete' i = int(com[1]) i int(com[1]) int com[1] com 1 try:
            L.remove(i)
        except ValueError:
            continue
     except ValueError:
            continue
     continue L.remove(i) L.remove L remove i elif com[0] == 'deleteFirst':
        L.popleft()
     com[0] == 'deleteFirst' com[0] com 0 'deleteFirst' L.popleft() L.popleft L popleft elif com[0] == 'deleteLast':
        L.pop() com[0] == 'deleteLast' com[0] com 0 'deleteLast' L.pop() L.pop L pop for i in range(len(L)):
    if i == len(L) - 1:
        print(L[i])
    else:
        print(L[i], end=' ') i range(len(L)) range len(L) len L if i == len(L) - 1:
        print(L[i])
    else:
        print(L[i], end=' ') i == len(L) - 1 i len(L) - 1 len(L) len L 1 print(L[i]) print L[i] L i print(L[i], end=' ') print L[i] L i end=' ' end ' ' com = list(map(str, stdin.readline().split())) list(map(str, stdin.readline().split())) com n = int(input()) int(input()) n L = deque() deque() L i = int(com[1]) int(com[1]) i i = int(com[1]) int(com[1]) i
from collections import deque
from sys import stdin
n = int(input())
L = deque()
for _ in range(n):
    com = list(map(str, stdin.readline().split()))
    if com[0] == 'insert':
        i = int(com[1])
        L.appendleft(i)
    elif com[0] == 'delete':
        i = int(com[1])
        try:
            L.remove(i)
        except ValueError:
            continue
    elif com[0] == 'deleteFirst':
        L.popleft()
    elif com[0] == 'deleteLast':
        L.pop()
for i in range(len(L)):
    if i == len(L) - 1:
        print(L[i])
    else:
        print(L[i], end=' ')
