from collections import deque

dll = deque()

n = int(input())
for _ in range(n):
    command = input()
    if command[0] == "i":
        dll.appendleft(command[7:])
    elif command[0] == "d":
        if command[6] == ' ':
            key = command[7:]
            if key in dll:
                dll.remove(key)
        elif command[6] == "F":
            dll.popleft()
        else:
            dll.pop()

print(' '.join(dll)) from collections import deque dll = deque() dll deque() deque n = int(input()) n int(input()) int input() input for _ in range(n):
    command = input()
    if command[0] == "i":
        dll.appendleft(command[7:])
    elif command[0] == "d":
        if command[6] == ' ':
            key = command[7:]
            if key in dll:
                dll.remove(key)
        elif command[6] == "F":
            dll.popleft()
        else:
            dll.pop() _ range(n) range n command = input() command input() input if command[0] == "i":
        dll.appendleft(command[7:])
    elif command[0] == "d":
        if command[6] == ' ':
            key = command[7:]
            if key in dll:
                dll.remove(key)
        elif command[6] == "F":
            dll.popleft()
        else:
            dll.pop() command[0] == "i" command[0] command 0 "i" dll.appendleft(command[7:]) dll.appendleft dll appendleft command[7:] command 7: 7 elif command[0] == "d":
        if command[6] == ' ':
            key = command[7:]
            if key in dll:
                dll.remove(key)
        elif command[6] == "F":
            dll.popleft()
        else:
            dll.pop() command[0] == "d" command[0] command 0 "d" if command[6] == ' ':
            key = command[7:]
            if key in dll:
                dll.remove(key)
        elif command[6] == "F":
            dll.popleft()
        else:
            dll.pop() command[6] == ' ' command[6] command 6 ' ' key = command[7:] key command[7:] command 7: 7 if key in dll:
                dll.remove(key)
         key in dll key dll dll.remove(key) dll.remove dll remove key elif command[6] == "F":
            dll.popleft()
         command[6] == "F" command[6] command 6 "F" dll.popleft() dll.popleft dll popleft dll.pop() dll.pop dll pop print(' '.join(dll)) print ' '.join(dll) ' '.join ' ' join dll n = int(input()) int(input()) n dll = deque() deque() dll command = input() input() command key = command[7:] command[7:] key
from collections import deque

dll = deque()

n = int(input())
for _ in range(n):
    command = input()
    if command[0] == "i":
        dll.appendleft(command[7:])
    elif command[0] == "d":
        if command[6] == ' ':
            key = command[7:]
            if key in dll:
                dll.remove(key)
        elif command[6] == "F":
            dll.popleft()
        else:
            dll.pop()

print(' '.join(dll))
