from collections import deque
dq = deque()
for _ in range(int(input())):
    ss = input()
    if ss == "deleteFirst":
        del dq[0]
    elif ss == "deleteLast":
        del dq[-1]
    else:
        c, s = ss.split()
        s = int(s)
        if c == "insert":
            dq.appendleft(s)
        elif c == "delete":
            if s in dq:
                dq.remove(s)
print(*dq)
 from collections import deque dq = deque() dq deque() deque for _ in range(int(input())):
    ss = input()
    if ss == "deleteFirst":
        del dq[0]
    elif ss == "deleteLast":
        del dq[-1]
    else:
        c, s = ss.split()
        s = int(s)
        if c == "insert":
            dq.appendleft(s)
        elif c == "delete":
            if s in dq:
                dq.remove(s) _ range(int(input())) range int(input()) int input() input ss = input() ss input() input if ss == "deleteFirst":
        del dq[0]
    elif ss == "deleteLast":
        del dq[-1]
    else:
        c, s = ss.split()
        s = int(s)
        if c == "insert":
            dq.appendleft(s)
        elif c == "delete":
            if s in dq:
                dq.remove(s) ss == "deleteFirst" ss "deleteFirst" del dq[0] dq[0] dq 0 elif ss == "deleteLast":
        del dq[-1]
     ss == "deleteLast" ss "deleteLast" del dq[-1] dq[-1] dq -1 c, s = ss.split() c ss.split() ss.split ss split s s = int(s) s int(s) int s if c == "insert":
            dq.appendleft(s)
        elif c == "delete":
            if s in dq:
                dq.remove(s) c == "insert" c "insert" dq.appendleft(s) dq.appendleft dq appendleft s elif c == "delete":
            if s in dq:
                dq.remove(s) c == "delete" c "delete" if s in dq:
                dq.remove(s) s in dq s dq dq.remove(s) dq.remove dq remove s print(*dq) print *dq dq dq = deque() deque() dq s = ss.split() ss.split() s c, s = ss.split() ss.split() c ss = input() input() ss s = int(s) int(s) s
from collections import deque
dq = deque()
for _ in range(int(input())):
    ss = input()
    if ss == "deleteFirst":
        del dq[0]
    elif ss == "deleteLast":
        del dq[-1]
    else:
        c, s = ss.split()
        s = int(s)
        if c == "insert":
            dq.appendleft(s)
        elif c == "delete":
            if s in dq:
                dq.remove(s)
print(*dq)

