import sys
from collections import deque

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

for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == "i":
        que.appendleft(command[7:])
    elif command[6] == " ":
        try:
            que.remove(command[7:])
        except:
            pass
    elif command[6] == "F":
        que.popleft()
    else:
        que.pop()
print(*que) import sys sys from collections import deque n = int(input()) n int(input()) int input() input que = deque() que deque() deque for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == "i":
        que.appendleft(command[7:])
    elif command[6] == " ":
        try:
            que.remove(command[7:])
        except:
            pass
    elif command[6] == "F":
        que.popleft()
    else:
        que.pop() i range(n) range n command = sys.stdin.readline()[:-1] command sys.stdin.readline()[:-1] sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline :-1 -1 if command[0] == "i":
        que.appendleft(command[7:])
    elif command[6] == " ":
        try:
            que.remove(command[7:])
        except:
            pass
    elif command[6] == "F":
        que.popleft()
    else:
        que.pop() command[0] == "i" command[0] command 0 "i" que.appendleft(command[7:]) que.appendleft que appendleft command[7:] command 7: 7 elif command[6] == " ":
        try:
            que.remove(command[7:])
        except:
            pass
     command[6] == " " command[6] command 6 " " try:
            que.remove(command[7:])
        except:
            pass
     except:
            pass
     que.remove(command[7:]) que.remove que remove command[7:] command 7: 7 elif command[6] == "F":
        que.popleft()
     command[6] == "F" command[6] command 6 "F" que.popleft() que.popleft que popleft que.pop() que.pop que pop print(*que) print *que que que = deque() deque() que n = int(input()) int(input()) n command = sys.stdin.readline()[:-1] sys.stdin.readline()[:-1] command
import sys
from collections import deque

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

for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == "i":
        que.appendleft(command[7:])
    elif command[6] == " ":
        try:
            que.remove(command[7:])
        except:
            pass
    elif command[6] == "F":
        que.popleft()
    else:
        que.pop()
print(*que)