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