from collections import deque

N = int(input().rstrip())

dll = deque()

for n in range(N):
    command = input().rstrip()
    if command.endswith(("First", "Last")):
        if command == "deleteFirst":
            dll.popleft()
        else:
            dll.pop()
    else:
        command, x = command.split(" ")
        if command =="insert":
            dll.appendleft(x)
        else:
            try:
                dll.remove(x)
            except Exception as e:
                pass
            
print(" ".join(dll)) from collections import deque N = int(input().rstrip()) N int(input().rstrip()) int input().rstrip() ().rstrip () input rstrip dll = deque() dll deque() deque for n in range(N):
    command = input().rstrip()
    if command.endswith(("First", "Last")):
        if command == "deleteFirst":
            dll.popleft()
        else:
            dll.pop()
    else:
        command, x = command.split(" ")
        if command =="insert":
            dll.appendleft(x)
        else:
            try:
                dll.remove(x)
            except Exception as e:
                pass
             n range(N) range N command = input().rstrip() command input().rstrip() ().rstrip () input rstrip if command.endswith(("First", "Last")):
        if command == "deleteFirst":
            dll.popleft()
        else:
            dll.pop()
    else:
        command, x = command.split(" ")
        if command =="insert":
            dll.appendleft(x)
        else:
            try:
                dll.remove(x)
            except Exception as e:
                pass
             command.endswith(("First", "Last")) command.endswith command endswith ("First", "Last") "First" "Last" if command == "deleteFirst":
            dll.popleft()
        else:
            dll.pop()
     command == "deleteFirst" command "deleteFirst" dll.popleft() dll.popleft dll popleft dll.pop() dll.pop dll pop command, x = command.split(" ") command command.split(" ") command.split command split " " x if command =="insert":
            dll.appendleft(x)
        else:
            try:
                dll.remove(x)
            except Exception as e:
                pass
             command =="insert" command "insert" dll.appendleft(x) dll.appendleft dll appendleft x try:
                dll.remove(x)
            except Exception as e:
                pass
             except Exception as e:
                pass
             dll.remove(x) dll.remove dll remove x print(" ".join(dll)) print " ".join(dll) " ".join " " join dll dll = deque() deque() dll command, x = command.split(" ") command.split(" ") command N = int(input().rstrip()) int(input().rstrip()) N x = command.split(" ") command.split(" ") x command = input().rstrip() input().rstrip() command
from collections import deque

N = int(input().rstrip())

dll = deque()

for n in range(N):
    command = input().rstrip()
    if command.endswith(("First", "Last")):
        if command == "deleteFirst":
            dll.popleft()
        else:
            dll.pop()
    else:
        command, x = command.split(" ")
        if command =="insert":
            dll.appendleft(x)
        else:
            try:
                dll.remove(x)
            except Exception as e:
                pass
            
print(" ".join(dll))
