from collections import deque

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

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

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

print(*l)
