from collections import deque
import sys
input = sys.stdin.readline

n = int(input())
lst = deque([])
for i in range(n):
    inp = input().split()
    op = inp[0]
    try:
        x = inp[1]
    except:
        pass
    if op == 'insert':
        lst.appendleft(x)
    if op == 'delete':
        try:
            lst.remove(x)
        except:
            pass
    if op == 'deleteFirst':
        lst.popleft()
    if op == 'deleteLast':
        lst.pop()
print(*lst)
 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 lst = deque([]) lst deque([]) deque [] for i in range(n):
    inp = input().split()
    op = inp[0]
    try:
        x = inp[1]
    except:
        pass
    if op == 'insert':
        lst.appendleft(x)
    if op == 'delete':
        try:
            lst.remove(x)
        except:
            pass
    if op == 'deleteFirst':
        lst.popleft()
    if op == 'deleteLast':
        lst.pop() i range(n) range n inp = input().split() inp input().split() ().split () input split op = inp[0] op inp[0] inp 0 try:
        x = inp[1]
    except:
        pass
     except:
        pass
     x = inp[1] x inp[1] inp 1 if op == 'insert':
        lst.appendleft(x)
     op == 'insert' op 'insert' lst.appendleft(x) lst.appendleft lst appendleft x if op == 'delete':
        try:
            lst.remove(x)
        except:
            pass
     op == 'delete' op 'delete' try:
            lst.remove(x)
        except:
            pass
     except:
            pass
     lst.remove(x) lst.remove lst remove x if op == 'deleteFirst':
        lst.popleft()
     op == 'deleteFirst' op 'deleteFirst' lst.popleft() lst.popleft lst popleft if op == 'deleteLast':
        lst.pop() op == 'deleteLast' op 'deleteLast' lst.pop() lst.pop lst pop print(*lst) print *lst lst n = int(input()) int(input()) n op = inp[0] inp[0] op inp = input().split() input().split() inp lst = deque([]) deque([]) lst x = inp[1] inp[1] x input = sys.stdin.readline sys.stdin.readline input
from collections import deque
import sys
input = sys.stdin.readline

n = int(input())
lst = deque([])
for i in range(n):
    inp = input().split()
    op = inp[0]
    try:
        x = inp[1]
    except:
        pass
    if op == 'insert':
        lst.appendleft(x)
    if op == 'delete':
        try:
            lst.remove(x)
        except:
            pass
    if op == 'deleteFirst':
        lst.popleft()
    if op == 'deleteLast':
        lst.pop()
print(*lst)

