from collections import deque

n = int(input())
queue = deque()

for _ in range(n):
    tmp = input().split()
    cmd = tmp[0]
    if cmd == 'insert':
        queue.appendleft(tmp[1])
    elif cmd == 'delete':
        try:
            queue.remove(tmp[1])
        except ValueError:
            pass
    elif cmd == 'deleteFirst':
        queue.popleft()
    else:
        queue.pop()

print(' '.join(queue))
 from collections import deque n = int(input()) n int(input()) int input() input queue = deque() queue deque() deque for _ in range(n):
    tmp = input().split()
    cmd = tmp[0]
    if cmd == 'insert':
        queue.appendleft(tmp[1])
    elif cmd == 'delete':
        try:
            queue.remove(tmp[1])
        except ValueError:
            pass
    elif cmd == 'deleteFirst':
        queue.popleft()
    else:
        queue.pop() _ range(n) range n tmp = input().split() tmp input().split() ().split () input split cmd = tmp[0] cmd tmp[0] tmp 0 if cmd == 'insert':
        queue.appendleft(tmp[1])
    elif cmd == 'delete':
        try:
            queue.remove(tmp[1])
        except ValueError:
            pass
    elif cmd == 'deleteFirst':
        queue.popleft()
    else:
        queue.pop() cmd == 'insert' cmd 'insert' queue.appendleft(tmp[1]) queue.appendleft queue appendleft tmp[1] tmp 1 elif cmd == 'delete':
        try:
            queue.remove(tmp[1])
        except ValueError:
            pass
     cmd == 'delete' cmd 'delete' try:
            queue.remove(tmp[1])
        except ValueError:
            pass
     except ValueError:
            pass
     queue.remove(tmp[1]) queue.remove queue remove tmp[1] tmp 1 elif cmd == 'deleteFirst':
        queue.popleft()
     cmd == 'deleteFirst' cmd 'deleteFirst' queue.popleft() queue.popleft queue popleft queue.pop() queue.pop queue pop print(' '.join(queue)) print ' '.join(queue) ' '.join ' ' join queue tmp = input().split() input().split() tmp n = int(input()) int(input()) n queue = deque() deque() queue cmd = tmp[0] tmp[0] cmd
from collections import deque

n = int(input())
queue = deque()

for _ in range(n):
    tmp = input().split()
    cmd = tmp[0]
    if cmd == 'insert':
        queue.appendleft(tmp[1])
    elif cmd == 'delete':
        try:
            queue.remove(tmp[1])
        except ValueError:
            pass
    elif cmd == 'deleteFirst':
        queue.popleft()
    else:
        queue.pop()

print(' '.join(queue))

