from collections import deque
import sys
n = int(sys.stdin.readline())
#lines = sys.stdin.readlines()
lines = [input() for i in range(n)]

deq = deque()
for i in range(n):
    o = lines[i].split()
    if o[0] == 'insert':
        deq.appendleft(o[1])
    elif o[0] == 'delete':
        try:
            deq.remove(o[1])
        except:
            continue
    elif o[0] == 'deleteFirst':
        deq.popleft()
    elif o[0] == 'deleteLast':
        deq.pop()

print(' '.join(deq)) from collections import deque import sys sys n = int(sys.stdin.readline()) n int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline input() for i in range(n) for i in range(n) i range(n) range n for i in range(n) input() input lines = [input() for i in range(n)] lines [input() for i in range(n)] deq = deque() deq deque() deque for i in range(n):
    o = lines[i].split()
    if o[0] == 'insert':
        deq.appendleft(o[1])
    elif o[0] == 'delete':
        try:
            deq.remove(o[1])
        except:
            continue
    elif o[0] == 'deleteFirst':
        deq.popleft()
    elif o[0] == 'deleteLast':
        deq.pop() i range(n) range n o = lines[i].split() o lines[i].split() [i].split [i] lines i split if o[0] == 'insert':
        deq.appendleft(o[1])
    elif o[0] == 'delete':
        try:
            deq.remove(o[1])
        except:
            continue
    elif o[0] == 'deleteFirst':
        deq.popleft()
    elif o[0] == 'deleteLast':
        deq.pop() o[0] == 'insert' o[0] o 0 'insert' deq.appendleft(o[1]) deq.appendleft deq appendleft o[1] o 1 elif o[0] == 'delete':
        try:
            deq.remove(o[1])
        except:
            continue
     o[0] == 'delete' o[0] o 0 'delete' try:
            deq.remove(o[1])
        except:
            continue
     except:
            continue
     continue deq.remove(o[1]) deq.remove deq remove o[1] o 1 elif o[0] == 'deleteFirst':
        deq.popleft()
     o[0] == 'deleteFirst' o[0] o 0 'deleteFirst' deq.popleft() deq.popleft deq popleft elif o[0] == 'deleteLast':
        deq.pop() o[0] == 'deleteLast' o[0] o 0 'deleteLast' deq.pop() deq.pop deq pop print(' '.join(deq)) print ' '.join(deq) ' '.join ' ' join deq deq = deque() deque() deq o = lines[i].split() lines[i].split() o n = int(sys.stdin.readline()) int(sys.stdin.readline()) n lines = [input() for i in range(n)] [input() for i in range(n)] lines
from collections import deque
import sys
n = int(sys.stdin.readline())
#lines = sys.stdin.readlines()
lines = [input() for i in range(n)]

deq = deque()
for i in range(n):
    o = lines[i].split()
    if o[0] == 'insert':
        deq.appendleft(o[1])
    elif o[0] == 'delete':
        try:
            deq.remove(o[1])
        except:
            continue
    elif o[0] == 'deleteFirst':
        deq.popleft()
    elif o[0] == 'deleteLast':
        deq.pop()

print(' '.join(deq))
