from collections import deque 

n=int(input())
l=deque()

for loop in range(n):
    command=input()
    
    if command=='deleteFirst':
        l.popleft()
    elif command=='deleteLast':
        l.pop()
    else:
        com,num=command.split()

        if com=='insert':
            l.appendleft(num)
        elif com=='delete':
            try:l.remove(num)
            except:pass
    
print(*l) from collections import deque n=int(input()) n int(input()) int input() input l=deque() l deque() deque for loop in range(n):
    command=input()
    
    if command=='deleteFirst':
        l.popleft()
    elif command=='deleteLast':
        l.pop()
    else:
        com,num=command.split()

        if com=='insert':
            l.appendleft(num)
        elif com=='delete':
            try:l.remove(num)
            except:pass
     loop range(n) range n command=input() command input() input if command=='deleteFirst':
        l.popleft()
    elif command=='deleteLast':
        l.pop()
    else:
        com,num=command.split()

        if com=='insert':
            l.appendleft(num)
        elif com=='delete':
            try:l.remove(num)
            except:pass
     command=='deleteFirst' command 'deleteFirst' l.popleft() l.popleft l popleft elif command=='deleteLast':
        l.pop()
     command=='deleteLast' command 'deleteLast' l.pop() l.pop l pop com,num=command.split() com command.split() command.split command split num if com=='insert':
            l.appendleft(num)
        elif com=='delete':
            try:l.remove(num)
            except:pass
     com=='insert' com 'insert' l.appendleft(num) l.appendleft l appendleft num elif com=='delete':
            try:l.remove(num)
            except:pass
     com=='delete' com 'delete' try:l.remove(num)
            except:pass
     except:pass
     print(*l) print *l l com,num=command.split() command.split() com l=deque() deque() l num=command.split() command.split() num command=input() input() command n=int(input()) int(input()) n
from collections import deque 

n=int(input())
l=deque()

for loop in range(n):
    command=input()
    
    if command=='deleteFirst':
        l.popleft()
    elif command=='deleteLast':
        l.pop()
    else:
        com,num=command.split()

        if com=='insert':
            l.appendleft(num)
        elif com=='delete':
            try:l.remove(num)
            except:pass
    
print(*l)
