import sys
from collections import deque

queue = deque()

for _ in range(int(sys.stdin.readline())):
    commands = sys.stdin.readline()[:-1].split(" ")
    if commands[0] == "insert":
        queue.appendleft(commands[1])
    elif commands[0] == "delete":
        try:
            queue.remove(commands[1])
        except ValueError:
            pass
    elif commands[0] == "deleteFirst":
        queue.popleft()
    elif commands[0] == "deleteLast":
        queue.pop()

print(" ".join(queue)) import sys sys from collections import deque queue = deque() queue deque() deque for _ in range(int(sys.stdin.readline())):
    commands = sys.stdin.readline()[:-1].split(" ")
    if commands[0] == "insert":
        queue.appendleft(commands[1])
    elif commands[0] == "delete":
        try:
            queue.remove(commands[1])
        except ValueError:
            pass
    elif commands[0] == "deleteFirst":
        queue.popleft()
    elif commands[0] == "deleteLast":
        queue.pop() _ range(int(sys.stdin.readline())) range int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline commands = sys.stdin.readline()[:-1].split(" ") commands sys.stdin.readline()[:-1].split(" ") [:-1].split [:-1] sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline :-1 -1 split " " if commands[0] == "insert":
        queue.appendleft(commands[1])
    elif commands[0] == "delete":
        try:
            queue.remove(commands[1])
        except ValueError:
            pass
    elif commands[0] == "deleteFirst":
        queue.popleft()
    elif commands[0] == "deleteLast":
        queue.pop() commands[0] == "insert" commands[0] commands 0 "insert" queue.appendleft(commands[1]) queue.appendleft queue appendleft commands[1] commands 1 elif commands[0] == "delete":
        try:
            queue.remove(commands[1])
        except ValueError:
            pass
     commands[0] == "delete" commands[0] commands 0 "delete" try:
            queue.remove(commands[1])
        except ValueError:
            pass
     except ValueError:
            pass
     queue.remove(commands[1]) queue.remove queue remove commands[1] commands 1 elif commands[0] == "deleteFirst":
        queue.popleft()
     commands[0] == "deleteFirst" commands[0] commands 0 "deleteFirst" queue.popleft() queue.popleft queue popleft elif commands[0] == "deleteLast":
        queue.pop() commands[0] == "deleteLast" commands[0] commands 0 "deleteLast" queue.pop() queue.pop queue pop print(" ".join(queue)) print " ".join(queue) " ".join " " join queue commands = sys.stdin.readline()[:-1].split(" ") sys.stdin.readline()[:-1].split(" ") commands queue = deque() deque() queue
import sys
from collections import deque

queue = deque()

for _ in range(int(sys.stdin.readline())):
    commands = sys.stdin.readline()[:-1].split(" ")
    if commands[0] == "insert":
        queue.appendleft(commands[1])
    elif commands[0] == "delete":
        try:
            queue.remove(commands[1])
        except ValueError:
            pass
    elif commands[0] == "deleteFirst":
        queue.popleft()
    elif commands[0] == "deleteLast":
        queue.pop()

print(" ".join(queue))