from collections import deque


n = int(input())
L = deque()

for i in range(n):
    com = input()
    if com[0] == 'i':
        C = com.split()
        L.appendleft(int(C[1]))
    else:
        if com[6] == 'F':
            L.popleft()
        elif com[6] == 'L':
            L.pop()
        else:
            C = com.split()
            x = int(C[1])
            try:
                L.remove(x)
            except:
                pass

print(*L) from collections import deque n = int(input()) n int(input()) int input() input L = deque() L deque() deque for i in range(n):
    com = input()
    if com[0] == 'i':
        C = com.split()
        L.appendleft(int(C[1]))
    else:
        if com[6] == 'F':
            L.popleft()
        elif com[6] == 'L':
            L.pop()
        else:
            C = com.split()
            x = int(C[1])
            try:
                L.remove(x)
            except:
                pass i range(n) range n com = input() com input() input if com[0] == 'i':
        C = com.split()
        L.appendleft(int(C[1]))
    else:
        if com[6] == 'F':
            L.popleft()
        elif com[6] == 'L':
            L.pop()
        else:
            C = com.split()
            x = int(C[1])
            try:
                L.remove(x)
            except:
                pass com[0] == 'i' com[0] com 0 'i' C = com.split() C com.split() com.split com split L.appendleft(int(C[1])) L.appendleft L appendleft int(C[1]) int C[1] C 1 if com[6] == 'F':
            L.popleft()
        elif com[6] == 'L':
            L.pop()
        else:
            C = com.split()
            x = int(C[1])
            try:
                L.remove(x)
            except:
                pass com[6] == 'F' com[6] com 6 'F' L.popleft() L.popleft L popleft elif com[6] == 'L':
            L.pop()
         com[6] == 'L' com[6] com 6 'L' L.pop() L.pop L pop C = com.split() C com.split() com.split com split x = int(C[1]) x int(C[1]) int C[1] C 1 try:
                L.remove(x)
            except:
                pass except:
                pass L.remove(x) L.remove L remove x print(*L) print *L L C = com.split() com.split() C x = int(C[1]) int(C[1]) x L = deque() deque() L com = input() input() com n = int(input()) int(input()) n C = com.split() com.split() C
from collections import deque


n = int(input())
L = deque()

for i in range(n):
    com = input()
    if com[0] == 'i':
        C = com.split()
        L.appendleft(int(C[1]))
    else:
        if com[6] == 'F':
            L.popleft()
        elif com[6] == 'L':
            L.pop()
        else:
            C = com.split()
            x = int(C[1])
            try:
                L.remove(x)
            except:
                pass

print(*L)
