from collections import deque

n=int(input())
que_r=deque()

for i in range(n):
    s=input()
    l=len(s)
    if s[0]=="i":
        que_r.appendleft(s[7:])
    elif s[6]==" ":
        try:
            que_r.remove(s[7:])
        except: pass
    elif l>10:
        que_r.popleft()
    elif l>6:
        que_r.pop()

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

n=int(input())
que_r=deque()

for i in range(n):
    s=input()
    l=len(s)
    if s[0]=="i":
        que_r.appendleft(s[7:])
    elif s[6]==" ":
        try:
            que_r.remove(s[7:])
        except: pass
    elif l>10:
        que_r.popleft()
    elif l>6:
        que_r.pop()

print(*que_r)
