from collections import deque
import sys

n = int(input())
deq = deque()

for _ in range(n):
    cmd = input()
    if cmd[0] == "i":
        deq.appendleft(cmd[7:])
    elif cmd[6] == "F":
        deq.popleft()
    elif cmd[6] == "L":
        deq.pop()
    else:
        try:
            deq.remove(cmd[7:])
        except:
            pass

print(" ".join(deq)) from collections import deque import sys sys n = int(input()) n int(input()) int input() input deq = deque() deq deque() deque for _ in range(n):
    cmd = input()
    if cmd[0] == "i":
        deq.appendleft(cmd[7:])
    elif cmd[6] == "F":
        deq.popleft()
    elif cmd[6] == "L":
        deq.pop()
    else:
        try:
            deq.remove(cmd[7:])
        except:
            pass _ range(n) range n cmd = input() cmd input() input if cmd[0] == "i":
        deq.appendleft(cmd[7:])
    elif cmd[6] == "F":
        deq.popleft()
    elif cmd[6] == "L":
        deq.pop()
    else:
        try:
            deq.remove(cmd[7:])
        except:
            pass cmd[0] == "i" cmd[0] cmd 0 "i" deq.appendleft(cmd[7:]) deq.appendleft deq appendleft cmd[7:] cmd 7: 7 elif cmd[6] == "F":
        deq.popleft()
     cmd[6] == "F" cmd[6] cmd 6 "F" deq.popleft() deq.popleft deq popleft elif cmd[6] == "L":
        deq.pop()
     cmd[6] == "L" cmd[6] cmd 6 "L" deq.pop() deq.pop deq pop try:
            deq.remove(cmd[7:])
        except:
            pass except:
            pass deq.remove(cmd[7:]) deq.remove deq remove cmd[7:] cmd 7: 7 print(" ".join(deq)) print " ".join(deq) " ".join " " join deq n = int(input()) int(input()) n deq = deque() deque() deq cmd = input() input() cmd
from collections import deque
import sys

n = int(input())
deq = deque()

for _ in range(n):
    cmd = input()
    if cmd[0] == "i":
        deq.appendleft(cmd[7:])
    elif cmd[6] == "F":
        deq.popleft()
    elif cmd[6] == "L":
        deq.pop()
    else:
        try:
            deq.remove(cmd[7:])
        except:
            pass

print(" ".join(deq))
