from collections import deque
num = deque()
n = int(input())
for i in range(n):
    com = input().split()
    if com[0] == "deleteFirst":
        num.popleft()
    elif com[0] == "deleteLast":
        num.pop()
    elif com[0] == "insert":
        num.insert(0, com[1])
    elif com[0] == "delete":
        if num.count(com[1]):
            num.remove(com[1])
print(" ".join(num)) from collections import deque num = deque() num deque() deque n = int(input()) n int(input()) int input() input for i in range(n):
    com = input().split()
    if com[0] == "deleteFirst":
        num.popleft()
    elif com[0] == "deleteLast":
        num.pop()
    elif com[0] == "insert":
        num.insert(0, com[1])
    elif com[0] == "delete":
        if num.count(com[1]):
            num.remove(com[1]) i range(n) range n com = input().split() com input().split() ().split () input split if com[0] == "deleteFirst":
        num.popleft()
    elif com[0] == "deleteLast":
        num.pop()
    elif com[0] == "insert":
        num.insert(0, com[1])
    elif com[0] == "delete":
        if num.count(com[1]):
            num.remove(com[1]) com[0] == "deleteFirst" com[0] com 0 "deleteFirst" num.popleft() num.popleft num popleft elif com[0] == "deleteLast":
        num.pop()
     com[0] == "deleteLast" com[0] com 0 "deleteLast" num.pop() num.pop num pop elif com[0] == "insert":
        num.insert(0, com[1])
     com[0] == "insert" com[0] com 0 "insert" num.insert(0, com[1]) num.insert num insert 0 com[1] com 1 elif com[0] == "delete":
        if num.count(com[1]):
            num.remove(com[1]) com[0] == "delete" com[0] com 0 "delete" if num.count(com[1]):
            num.remove(com[1]) num.count(com[1]) num.count num count com[1] com 1 num.remove(com[1]) num.remove num remove com[1] com 1 print(" ".join(num)) print " ".join(num) " ".join " " join num n = int(input()) int(input()) n num = deque() deque() num com = input().split() input().split() com
from collections import deque
num = deque()
n = int(input())
for i in range(n):
    com = input().split()
    if com[0] == "deleteFirst":
        num.popleft()
    elif com[0] == "deleteLast":
        num.pop()
    elif com[0] == "insert":
        num.insert(0, com[1])
    elif com[0] == "delete":
        if num.count(com[1]):
            num.remove(com[1])
print(" ".join(num))
