from collections import deque
import sys

input = sys.stdin.readline

n = int(input())
Qs = deque()

for i in range(n):
    
    OPs = input().split()
    
    op = OPs[0]
    
    if op[0] == 'i':
        Qs.appendleft(OPs[1])
        continue
    if op == 'delete':
        try:
            Qs.remove(OPs[1])
        except ValueError:
            pass
        continue
    if op == 'deleteFirst':
        Qs.popleft()
        continue
    if op == 'deleteLast':
        Qs.pop()
        continue

print(" ".join(map(str, Qs))) from collections import deque import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n = int(input()) n int(input()) int input() input Qs = deque() Qs deque() deque for i in range(n):
    
    OPs = input().split()
    
    op = OPs[0]
    
    if op[0] == 'i':
        Qs.appendleft(OPs[1])
        continue
    if op == 'delete':
        try:
            Qs.remove(OPs[1])
        except ValueError:
            pass
        continue
    if op == 'deleteFirst':
        Qs.popleft()
        continue
    if op == 'deleteLast':
        Qs.pop()
        continue i range(n) range n OPs = input().split() OPs input().split() ().split () input split op = OPs[0] op OPs[0] OPs 0 if op[0] == 'i':
        Qs.appendleft(OPs[1])
        continue
     op[0] == 'i' op[0] op 0 'i' Qs.appendleft(OPs[1]) Qs.appendleft Qs appendleft OPs[1] OPs 1 continue if op == 'delete':
        try:
            Qs.remove(OPs[1])
        except ValueError:
            pass
        continue
     op == 'delete' op 'delete' try:
            Qs.remove(OPs[1])
        except ValueError:
            pass
         except ValueError:
            pass
         Qs.remove(OPs[1]) Qs.remove Qs remove OPs[1] OPs 1 continue if op == 'deleteFirst':
        Qs.popleft()
        continue
     op == 'deleteFirst' op 'deleteFirst' Qs.popleft() Qs.popleft Qs popleft continue if op == 'deleteLast':
        Qs.pop()
        continue op == 'deleteLast' op 'deleteLast' Qs.pop() Qs.pop Qs pop continue print(" ".join(map(str, Qs))) print " ".join(map(str, Qs)) " ".join " " join map(str, Qs) map str Qs n = int(input()) int(input()) n input = sys.stdin.readline sys.stdin.readline input OPs = input().split() input().split() OPs op = OPs[0] OPs[0] op Qs = deque() deque() Qs
from collections import deque
import sys

input = sys.stdin.readline

n = int(input())
Qs = deque()

for i in range(n):
    
    OPs = input().split()
    
    op = OPs[0]
    
    if op[0] == 'i':
        Qs.appendleft(OPs[1])
        continue
    if op == 'delete':
        try:
            Qs.remove(OPs[1])
        except ValueError:
            pass
        continue
    if op == 'deleteFirst':
        Qs.popleft()
        continue
    if op == 'deleteLast':
        Qs.pop()
        continue

print(" ".join(map(str, Qs)))
