from collections import deque

n = int(input())
q = deque()

for i in range(n):
    command = input()
    if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop()

print(' '.join(q)) from collections import deque n = int(input()) n int(input()) int input() input q = deque() q deque() deque for i in range(n):
    command = input()
    if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop() i range(n) range n command = input() command input() input if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop() command[0] == 'i' command[0] command 0 'i' q.appendleft(command[7:]) q.appendleft q appendleft command[7:] command 7: 7 elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
     command[6] == ' ' command[6] command 6 ' ' try:
            q.remove(command[7:])
        except Exception as e:
            pass
     except Exception as e:
            pass
     q.remove(command[7:]) q.remove q remove command[7:] command 7: 7 elif command[6] == 'F':
        q.popleft()
     command[6] == 'F' command[6] command 6 'F' q.popleft() q.popleft q popleft q.pop() q.pop q pop print(' '.join(q)) print ' '.join(q) ' '.join ' ' join q n = int(input()) int(input()) n q = deque() deque() q command = input() input() command
from collections import deque

n = int(input())
q = deque()

for i in range(n):
    command = input()
    if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop()

print(' '.join(q))