from collections import deque

d=deque()

N=int(input())

for n in range(N):
    a=input()
    if a=="deleteFirst":
        d.popleft()
    elif a=="deleteLast":
        d.pop()
    else:
        a,b=a.split()
        if a=="insert":
            d.appendleft(b)
        elif a=="delete":
            if d.count(b):
                d.remove(b)
                
print(' '.join(list(d)))
 from collections import deque d=deque() d deque() deque N=int(input()) N int(input()) int input() input for n in range(N):
    a=input()
    if a=="deleteFirst":
        d.popleft()
    elif a=="deleteLast":
        d.pop()
    else:
        a,b=a.split()
        if a=="insert":
            d.appendleft(b)
        elif a=="delete":
            if d.count(b):
                d.remove(b)
                 n range(N) range N a=input() a input() input if a=="deleteFirst":
        d.popleft()
    elif a=="deleteLast":
        d.pop()
    else:
        a,b=a.split()
        if a=="insert":
            d.appendleft(b)
        elif a=="delete":
            if d.count(b):
                d.remove(b)
                 a=="deleteFirst" a "deleteFirst" d.popleft() d.popleft d popleft elif a=="deleteLast":
        d.pop()
     a=="deleteLast" a "deleteLast" d.pop() d.pop d pop a,b=a.split() a a.split() a.split a split b if a=="insert":
            d.appendleft(b)
        elif a=="delete":
            if d.count(b):
                d.remove(b)
                 a=="insert" a "insert" d.appendleft(b) d.appendleft d appendleft b elif a=="delete":
            if d.count(b):
                d.remove(b)
                 a=="delete" a "delete" if d.count(b):
                d.remove(b)
                 d.count(b) d.count d count b d.remove(b) d.remove d remove b print(' '.join(list(d))) print ' '.join(list(d)) ' '.join ' ' join list(d) list d a=input() input() a d=deque() deque() d b=a.split() a.split() b N=int(input()) int(input()) N a,b=a.split() a.split() a
from collections import deque

d=deque()

N=int(input())

for n in range(N):
    a=input()
    if a=="deleteFirst":
        d.popleft()
    elif a=="deleteLast":
        d.pop()
    else:
        a,b=a.split()
        if a=="insert":
            d.appendleft(b)
        elif a=="delete":
            if d.count(b):
                d.remove(b)
                
print(' '.join(list(d)))

