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