import sys

from collections import deque

readline = sys.stdin.readline

dq = deque()

for _ in range(int(eval(input()))):

    ss = readline().strip()

    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))



import sys

from collections import deque

readline = sys.stdin.readline

dq = deque()

for _ in range(int(eval(input()))):

    c = readline().split()

    if c[0] == "deleteFirst":

        del dq[0]

    elif c[0] == "deleteLast":

        del dq[-1]

    else:

        if c[0] == "insert":

            dq.appendleft(c[1])

        elif c[0] == "delete":

            if c[1] in dq:

                dq.remove(c[1])

print((*dq))



import sys
from collections import deque

readline = sys.stdin.readline
dq = deque()
for _ in range(int(eval(input()))):
    ss = readline().strip()
    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))

import sys
from collections import deque

readline = sys.stdin.readline
dq = deque()
for _ in range(int(eval(input()))):
    c = readline().split()
    if c[0] == "deleteFirst":
        del dq[0]
    elif c[0] == "deleteLast":
        del dq[-1]
    else:
        if c[0] == "insert":
            dq.appendleft(c[1])
        elif c[0] == "delete":
            if c[1] in dq:
                dq.remove(c[1])
print((*dq))

-    ss = readline().strip() -    if ss == "deleteFirst": +    c = readline().split() +    if c[0] == "deleteFirst": -    elif ss == "deleteLast": +    elif c[0] == "deleteLast": -        c, s = ss.split() -        s = int(s) -        if c == "insert": -            dq.appendleft(s) -        elif c == "delete": -            if s in dq: -                dq.remove(s) +        if c[0] == "insert": +            dq.appendleft(c[1]) +        elif c[0] == "delete": +            if c[1] in dq: +                dq.remove(c[1])