from collections import deque

n = int(input())
a = deque()

for _ in range(n):
    b = input()
    if b[0] == "i":
        a.appendleft(b[7:])
    elif b[6] == " ":
        try:
            a.remove(b[7:])
        except:
            pass
    elif len(b) > 10:
        a.popleft()
    else:
        a.pop()
print(*a)
 from collections import deque n = int(input()) n int(input()) int input() input a = deque() a deque() deque for _ in range(n):
    b = input()
    if b[0] == "i":
        a.appendleft(b[7:])
    elif b[6] == " ":
        try:
            a.remove(b[7:])
        except:
            pass
    elif len(b) > 10:
        a.popleft()
    else:
        a.pop() _ range(n) range n b = input() b input() input if b[0] == "i":
        a.appendleft(b[7:])
    elif b[6] == " ":
        try:
            a.remove(b[7:])
        except:
            pass
    elif len(b) > 10:
        a.popleft()
    else:
        a.pop() b[0] == "i" b[0] b 0 "i" a.appendleft(b[7:]) a.appendleft a appendleft b[7:] b 7: 7 elif b[6] == " ":
        try:
            a.remove(b[7:])
        except:
            pass
     b[6] == " " b[6] b 6 " " try:
            a.remove(b[7:])
        except:
            pass
     except:
            pass
     a.remove(b[7:]) a.remove a remove b[7:] b 7: 7 elif len(b) > 10:
        a.popleft()
     len(b) > 10 len(b) len b 10 a.popleft() a.popleft a popleft a.pop() a.pop a pop print(*a) print *a a n = int(input()) int(input()) n a = deque() deque() a b = input() input() b
from collections import deque

n = int(input())
a = deque()

for _ in range(n):
    b = input()
    if b[0] == "i":
        a.appendleft(b[7:])
    elif b[6] == " ":
        try:
            a.remove(b[7:])
        except:
            pass
    elif len(b) > 10:
        a.popleft()
    else:
        a.pop()
print(*a)

