from collections import deque

N = int(input())

d = deque([])
for i 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)
        else:
            try:
                d.remove(b)
            except:
                pass

print(*d) from collections import deque N = int(input()) N int(input()) int input() input d = deque([]) d deque([]) deque [] for i 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)
        else:
            try:
                d.remove(b)
            except:
                pass i 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)
        else:
            try:
                d.remove(b)
            except:
                pass 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)
        else:
            try:
                d.remove(b)
            except:
                pass a == "insert" a "insert" d.appendleft(b) d.appendleft d appendleft b try:
                d.remove(b)
            except:
                pass except:
                pass d.remove(b) d.remove d remove b print(*d) print *d d N = int(input()) int(input()) N a, b = a.split() a.split() a d = deque([]) deque([]) d a = input() input() a b = a.split() a.split() b
from collections import deque

N = int(input())

d = deque([])
for i 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)
        else:
            try:
                d.remove(b)
            except:
                pass

print(*d)
