from collections import deque

n=int(input())
que=deque()

for i in range(n):
    command=input()

    if command=="deleteFirst":
        que.popleft()
    elif command=="deleteLast":
        que.pop()
    else:
        command,num=command.split()
        num=int(num)
        if command=="insert":
            que.appendleft(num)
        else:
            if num in que:
                que.remove(num)

print(*que,sep=" ") from collections import deque n=int(input()) n int(input()) int input() input que=deque() que deque() deque for i in range(n):
    command=input()

    if command=="deleteFirst":
        que.popleft()
    elif command=="deleteLast":
        que.pop()
    else:
        command,num=command.split()
        num=int(num)
        if command=="insert":
            que.appendleft(num)
        else:
            if num in que:
                que.remove(num) i range(n) range n command=input() command input() input if command=="deleteFirst":
        que.popleft()
    elif command=="deleteLast":
        que.pop()
    else:
        command,num=command.split()
        num=int(num)
        if command=="insert":
            que.appendleft(num)
        else:
            if num in que:
                que.remove(num) command=="deleteFirst" command "deleteFirst" que.popleft() que.popleft que popleft elif command=="deleteLast":
        que.pop()
     command=="deleteLast" command "deleteLast" que.pop() que.pop que pop command,num=command.split() command command.split() command.split command split num num=int(num) num int(num) int num if command=="insert":
            que.appendleft(num)
        else:
            if num in que:
                que.remove(num) command=="insert" command "insert" que.appendleft(num) que.appendleft que appendleft num if num in que:
                que.remove(num) num in que num que que.remove(num) que.remove que remove num print(*que,sep=" ") print *que que sep=" " sep " " command,num=command.split() command.split() command num=command.split() command.split() num num=int(num) int(num) num n=int(input()) int(input()) n que=deque() deque() que command=input() input() command
from collections import deque

n=int(input())
que=deque()

for i in range(n):
    command=input()

    if command=="deleteFirst":
        que.popleft()
    elif command=="deleteLast":
        que.pop()
    else:
        command,num=command.split()
        num=int(num)
        if command=="insert":
            que.appendleft(num)
        else:
            if num in que:
                que.remove(num)

print(*que,sep=" ")
