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

print(" ".join(l)) from collections import deque n = int(input()) n int(input()) int input() input l = deque() l deque() deque for i in range(n):
    command = input()
    if command == "deleteFirst":
        l.popleft()
    elif command == "deleteLast":
        l.pop()
    else:
        order, num = command.split()
        if order == "insert":
            l.appendleft(num)
        elif order == "delete":
            try:
                l.remove(num)
            except:
                pass i range(n) range n command = input() command input() input if command == "deleteFirst":
        l.popleft()
    elif command == "deleteLast":
        l.pop()
    else:
        order, num = command.split()
        if order == "insert":
            l.appendleft(num)
        elif order == "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 order, num = command.split() order command.split() command.split command split num if order == "insert":
            l.appendleft(num)
        elif order == "delete":
            try:
                l.remove(num)
            except:
                pass order == "insert" order "insert" l.appendleft(num) l.appendleft l appendleft num elif order == "delete":
            try:
                l.remove(num)
            except:
                pass order == "delete" order "delete" try:
                l.remove(num)
            except:
                pass except:
                pass l.remove(num) l.remove l remove num print(" ".join(l)) print " ".join(l) " ".join " " join l num = command.split() command.split() num order, num = command.split() command.split() order command = input() input() command l = deque() deque() l n = int(input()) int(input()) n
from collections import deque
n = int(input())
l = deque()
for i in range(n):
    command = input()
    if command == "deleteFirst":
        l.popleft()
    elif command == "deleteLast":
        l.pop()
    else:
        order, num = command.split()
        if order == "insert":
            l.appendleft(num)
        elif order == "delete":
            try:
                l.remove(num)
            except:
                pass

print(" ".join(l))
