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:
        x,y=command.split()
        if x=="insert":que.appendleft(y)
        else:
            if y in que:que.remove(y)

print(*que) 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:
        x,y=command.split()
        if x=="insert":que.appendleft(y)
        else:
            if y in que:que.remove(y) i range(n) range n command=input() command input() input if command=="deleteFirst":que.popleft()
    elif command=="deleteLast":que.pop()
    else:
        x,y=command.split()
        if x=="insert":que.appendleft(y)
        else:
            if y in que:que.remove(y) command=="deleteFirst" command "deleteFirst" elif command=="deleteLast":que.pop()
     command=="deleteLast" command "deleteLast" x,y=command.split() x command.split() command.split command split y if x=="insert":que.appendleft(y)
        else:
            if y in que:que.remove(y) x=="insert" x "insert" if y in que:q y in que y que print(*que) print *que que command=input() input() command que=deque() deque() que n=int(input()) int(input()) n y=command.split() command.split() y x,y=command.split() command.split() x
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:
        x,y=command.split()
        if x=="insert":que.appendleft(y)
        else:
            if y in que:que.remove(y)

print(*que)
