from collections import deque


n = int(input())
a = deque()

for i in range(n):
        s = input()
        if s == 'deleteFirst':
                a.popleft()
        elif s == 'deleteLast':
                a.pop()
        else:     
            s ,t = s.split()
            if s == 'insert':
                a.appendleft(t)
            elif s == 'delete':
                if t in  a:
                    a.remove(t)
        
print(*a, sep = ' ') from collections import deque n = int(input()) n int(input()) int input() input a = deque() a deque() deque for i in range(n):
        s = input()
        if s == 'deleteFirst':
                a.popleft()
        elif s == 'deleteLast':
                a.pop()
        else:     
            s ,t = s.split()
            if s == 'insert':
                a.appendleft(t)
            elif s == 'delete':
                if t in  a:
                    a.remove(t)
         i range(n) range n s = input() s input() input if s == 'deleteFirst':
                a.popleft()
        elif s == 'deleteLast':
                a.pop()
        else:     
            s ,t = s.split()
            if s == 'insert':
                a.appendleft(t)
            elif s == 'delete':
                if t in  a:
                    a.remove(t)
         s == 'deleteFirst' s 'deleteFirst' a.popleft() a.popleft a popleft elif s == 'deleteLast':
                a.pop()
         s == 'deleteLast' s 'deleteLast' a.pop() a.pop a pop s ,t = s.split() s s.split() s.split s split t if s == 'insert':
                a.appendleft(t)
            elif s == 'delete':
                if t in  a:
                    a.remove(t)
         s == 'insert' s 'insert' a.appendleft(t) a.appendleft a appendleft t elif s == 'delete':
                if t in  a:
                    a.remove(t)
         s == 'delete' s 'delete' if t in  a:
                    a.remove(t)
         t in  a t a a.remove(t) a.remove a remove t print(*a, sep = ' ') print *a a sep = ' ' sep ' ' n = int(input()) int(input()) n s ,t = s.split() s.split() s t = s.split() s.split() t a = deque() deque() a s = input() input() s
from collections import deque


n = int(input())
a = deque()

for i in range(n):
        s = input()
        if s == 'deleteFirst':
                a.popleft()
        elif s == 'deleteLast':
                a.pop()
        else:     
            s ,t = s.split()
            if s == 'insert':
                a.appendleft(t)
            elif s == 'delete':
                if t in  a:
                    a.remove(t)
        
print(*a, sep = ' ')
