from collections import deque

l = deque([])
n = int(input())
for i in range(n):
    com = input()
    if com == "deleteFirst":
        a = l.popleft()
    elif com == "deleteLast":
        a = l.pop()
    else:
        m = com.split()
        if m[0] == "insert":
            l.appendleft(m[1])
        else:
            try:
                l.remove(m[1])
            except:
                a = 1
print(" ".join(l)) from collections import deque l = deque([]) l deque([]) deque [] n = int(input()) n int(input()) int input() input for i in range(n):
    com = input()
    if com == "deleteFirst":
        a = l.popleft()
    elif com == "deleteLast":
        a = l.pop()
    else:
        m = com.split()
        if m[0] == "insert":
            l.appendleft(m[1])
        else:
            try:
                l.remove(m[1])
            except:
                a = 1 i range(n) range n com = input() com input() input if com == "deleteFirst":
        a = l.popleft()
    elif com == "deleteLast":
        a = l.pop()
    else:
        m = com.split()
        if m[0] == "insert":
            l.appendleft(m[1])
        else:
            try:
                l.remove(m[1])
            except:
                a = 1 com == "deleteFirst" com "deleteFirst" a = l.popleft() a l.popleft() l.popleft l popleft elif com == "deleteLast":
        a = l.pop()
     com == "deleteLast" com "deleteLast" a = l.pop() a l.pop() l.pop l pop m = com.split() m com.split() com.split com split if m[0] == "insert":
            l.appendleft(m[1])
        else:
            try:
                l.remove(m[1])
            except:
                a = 1 m[0] == "insert" m[0] m 0 "insert" l.appendleft(m[1]) l.appendleft l appendleft m[1] m 1 try:
                l.remove(m[1])
            except:
                a = 1 except:
                a = 1 a = 1 a 1 l.remove(m[1]) l.remove l remove m[1] m 1 print(" ".join(l)) print " ".join(l) " ".join " " join l m = com.split() com.split() m a = l.pop() l.pop() a com = input() input() com a = l.popleft() l.popleft() a l = deque([]) deque([]) l n = int(input()) int(input()) n a = 1 1 a
from collections import deque

l = deque([])
n = int(input())
for i in range(n):
    com = input()
    if com == "deleteFirst":
        a = l.popleft()
    elif com == "deleteLast":
        a = l.pop()
    else:
        m = com.split()
        if m[0] == "insert":
            l.appendleft(m[1])
        else:
            try:
                l.remove(m[1])
            except:
                a = 1
print(" ".join(l))