from collections import deque
import sys


deq = deque()

q = int(input())

for _ in range(q):
    s = input()
    if s == 'deleteFirst':
        deq.popleft()
    elif s == 'deleteLast':
        deq.pop()
    else:
        ss, num = s.split()
        if ss == 'insert':
            deq.appendleft(num)
        else:
            try:
                deq.remove(num)
            except:
                pass

print(" ".join(deq))

 from collections import deque import sys sys deq = deque() deq deque() deque q = int(input()) q int(input()) int input() input for _ in range(q):
    s = input()
    if s == 'deleteFirst':
        deq.popleft()
    elif s == 'deleteLast':
        deq.pop()
    else:
        ss, num = s.split()
        if ss == 'insert':
            deq.appendleft(num)
        else:
            try:
                deq.remove(num)
            except:
                pass _ range(q) range q s = input() s input() input if s == 'deleteFirst':
        deq.popleft()
    elif s == 'deleteLast':
        deq.pop()
    else:
        ss, num = s.split()
        if ss == 'insert':
            deq.appendleft(num)
        else:
            try:
                deq.remove(num)
            except:
                pass s == 'deleteFirst' s 'deleteFirst' deq.popleft() deq.popleft deq popleft elif s == 'deleteLast':
        deq.pop()
     s == 'deleteLast' s 'deleteLast' deq.pop() deq.pop deq pop ss, num = s.split() ss s.split() s.split s split num if ss == 'insert':
            deq.appendleft(num)
        else:
            try:
                deq.remove(num)
            except:
                pass ss == 'insert' ss 'insert' deq.appendleft(num) deq.appendleft deq appendleft num try:
                deq.remove(num)
            except:
                pass except:
                pass deq.remove(num) deq.remove deq remove num print(" ".join(deq)) print " ".join(deq) " ".join " " join deq s = input() input() s ss, num = s.split() s.split() ss deq = deque() deque() deq q = int(input()) int(input()) q num = s.split() s.split() num
from collections import deque
import sys


deq = deque()

q = int(input())

for _ in range(q):
    s = input()
    if s == 'deleteFirst':
        deq.popleft()
    elif s == 'deleteLast':
        deq.pop()
    else:
        ss, num = s.split()
        if ss == 'insert':
            deq.appendleft(num)
        else:
            try:
                deq.remove(num)
            except:
                pass

print(" ".join(deq))


