from collections import deque
n = int(input())
a = deque()
for i in range(n):
    c = input()
    if c == "deleteFirst":
        a.popleft()
    elif c == "deleteLast":
        a.pop()
    else:
        c, v = c.split()
        if c == "insert":
            a.appendleft(v)
        else:
            try:
                a.remove(v)
            except:
                pass
print(" ".join(a)) from collections import deque n = int(input()) n int(input()) int input() input a = deque() a deque() deque for i in range(n):
    c = input()
    if c == "deleteFirst":
        a.popleft()
    elif c == "deleteLast":
        a.pop()
    else:
        c, v = c.split()
        if c == "insert":
            a.appendleft(v)
        else:
            try:
                a.remove(v)
            except:
                pass i range(n) range n c = input() c input() input if c == "deleteFirst":
        a.popleft()
    elif c == "deleteLast":
        a.pop()
    else:
        c, v = c.split()
        if c == "insert":
            a.appendleft(v)
        else:
            try:
                a.remove(v)
            except:
                pass c == "deleteFirst" c "deleteFirst" a.popleft() a.popleft a popleft elif c == "deleteLast":
        a.pop()
     c == "deleteLast" c "deleteLast" a.pop() a.pop a pop c, v = c.split() c c.split() c.split c split v if c == "insert":
            a.appendleft(v)
        else:
            try:
                a.remove(v)
            except:
                pass c == "insert" c "insert" a.appendleft(v) a.appendleft a appendleft v try:
                a.remove(v)
            except:
                pass except:
                pass a.remove(v) a.remove a remove v print(" ".join(a)) print " ".join(a) " ".join " " join a a = deque() deque() a n = int(input()) int(input()) n c = input() input() c v = c.split() c.split() v c, v = c.split() c.split() c
from collections import deque
n = int(input())
a = deque()
for i in range(n):
    c = input()
    if c == "deleteFirst":
        a.popleft()
    elif c == "deleteLast":
        a.pop()
    else:
        c, v = c.split()
        if c == "insert":
            a.appendleft(v)
        else:
            try:
                a.remove(v)
            except:
                pass
print(" ".join(a))
