import collections
q = collections.deque()
n = int(input())
for i in range(n):
    com = input().split()
    if com[0] == 'insert':
        q.appendleft(int(com[1]))
    elif com[0] == 'delete':
        try:
            q.remove(int(com[1]))
        except:
            pass
    elif com[0] == 'deleteFirst':
        q.popleft()
    elif com[0] == 'deleteLast':
        q.pop()
print(*q) import collections collections q = collections.deque() q collections.deque() collections.deque collections deque n = int(input()) n int(input()) int input() input for i in range(n):
    com = input().split()
    if com[0] == 'insert':
        q.appendleft(int(com[1]))
    elif com[0] == 'delete':
        try:
            q.remove(int(com[1]))
        except:
            pass
    elif com[0] == 'deleteFirst':
        q.popleft()
    elif com[0] == 'deleteLast':
        q.pop() i range(n) range n com = input().split() com input().split() ().split () input split if com[0] == 'insert':
        q.appendleft(int(com[1]))
    elif com[0] == 'delete':
        try:
            q.remove(int(com[1]))
        except:
            pass
    elif com[0] == 'deleteFirst':
        q.popleft()
    elif com[0] == 'deleteLast':
        q.pop() com[0] == 'insert' com[0] com 0 'insert' q.appendleft(int(com[1])) q.appendleft q appendleft int(com[1]) int com[1] com 1 elif com[0] == 'delete':
        try:
            q.remove(int(com[1]))
        except:
            pass
     com[0] == 'delete' com[0] com 0 'delete' try:
            q.remove(int(com[1]))
        except:
            pass
     except:
            pass
     q.remove(int(com[1])) q.remove q remove int(com[1]) int com[1] com 1 elif com[0] == 'deleteFirst':
        q.popleft()
     com[0] == 'deleteFirst' com[0] com 0 'deleteFirst' q.popleft() q.popleft q popleft elif com[0] == 'deleteLast':
        q.pop() com[0] == 'deleteLast' com[0] com 0 'deleteLast' q.pop() q.pop q pop print(*q) print *q q com = input().split() input().split() com q = collections.deque() collections.deque() q n = int(input()) int(input()) n
import collections
q = collections.deque()
n = int(input())
for i in range(n):
    com = input().split()
    if com[0] == 'insert':
        q.appendleft(int(com[1]))
    elif com[0] == 'delete':
        try:
            q.remove(int(com[1]))
        except:
            pass
    elif com[0] == 'deleteFirst':
        q.popleft()
    elif com[0] == 'deleteLast':
        q.pop()
print(*q)