from collections import deque
dq = deque()
for _ in [None]*int(input()):
    s = input()
    if s == "deleteFirst":
        dq.popleft()
    elif s == "deleteLast":
        dq.pop()
    else:
        a, b = s.split()
        if a == "insert":
            dq.appendleft(b)
        else:
            if b in dq:
                dq.remove(b)
print(" ".join(dq))
 from collections import deque dq = deque() dq deque() deque for _ in [None]*int(input()):
    s = input()
    if s == "deleteFirst":
        dq.popleft()
    elif s == "deleteLast":
        dq.pop()
    else:
        a, b = s.split()
        if a == "insert":
            dq.appendleft(b)
        else:
            if b in dq:
                dq.remove(b) _ [None]*int(input()) [None] None int(input()) int input() input s = input() s input() input if s == "deleteFirst":
        dq.popleft()
    elif s == "deleteLast":
        dq.pop()
    else:
        a, b = s.split()
        if a == "insert":
            dq.appendleft(b)
        else:
            if b in dq:
                dq.remove(b) s == "deleteFirst" s "deleteFirst" dq.popleft() dq.popleft dq popleft elif s == "deleteLast":
        dq.pop()
     s == "deleteLast" s "deleteLast" dq.pop() dq.pop dq pop a, b = s.split() a s.split() s.split s split b if a == "insert":
            dq.appendleft(b)
        else:
            if b in dq:
                dq.remove(b) a == "insert" a "insert" dq.appendleft(b) dq.appendleft dq appendleft b if b in dq:
                dq.remove(b) b in dq b dq dq.remove(b) dq.remove dq remove b print(" ".join(dq)) print " ".join(dq) " ".join " " join dq b = s.split() s.split() b dq = deque() deque() dq a, b = s.split() s.split() a s = input() input() s
from collections import deque
dq = deque()
for _ in [None]*int(input()):
    s = input()
    if s == "deleteFirst":
        dq.popleft()
    elif s == "deleteLast":
        dq.pop()
    else:
        a, b = s.split()
        if a == "insert":
            dq.appendleft(b)
        else:
            if b in dq:
                dq.remove(b)
print(" ".join(dq))

