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

