from sys import stdin



n = int(stdin.readline())

q = []

bottom = 0

for i in range(n):

    cmd = stdin.readline()[:-1]

    if cmd[0] == 'i':

        q.append(cmd[7:])

    elif cmd[6] == ' ':

        try:

            q.pop(~q[::-1].index(cmd[7:]))

        except:

            pass

    elif cmd[6] == 'F':

        q.pop()

    else:

        bottom += 1



print((' '.join(q[bottom:][::-1])))
import sys

from collections import deque



n = int(sys.stdin.readline())

q = deque()

for i in range(n):

    cmd = sys.stdin.readline()[:-1]

    if cmd[0] == 'i':

        q.appendleft(cmd[7:])

    elif cmd[6] == ' ':

        try:

            q.remove(cmd[7:])

        except:

            pass

    elif cmd[6] == 'F':

        q.popleft()

    else:

        q.pop()



print((' '.join(q)))
from sys import stdin

n = int(stdin.readline())
q = []
bottom = 0
for i in range(n):
    cmd = stdin.readline()[:-1]
    if cmd[0] == "i":
        q.append(cmd[7:])
    elif cmd[6] == " ":
        try:
            q.pop(~q[::-1].index(cmd[7:]))
        except:
            pass
    elif cmd[6] == "F":
        q.pop()
    else:
        bottom += 1
print((" ".join(q[bottom:][::-1])))

import sys
from collections import deque

n = int(sys.stdin.readline())
q = deque()
for i in range(n):
    cmd = sys.stdin.readline()[:-1]
    if cmd[0] == "i":
        q.appendleft(cmd[7:])
    elif cmd[6] == " ":
        try:
            q.remove(cmd[7:])
        except:
            pass
    elif cmd[6] == "F":
        q.popleft()
    else:
        q.pop()
print((" ".join(q)))

-from sys import stdin +import sys +from collections import deque -n = int(stdin.readline()) -q = [] -bottom = 0 +n = int(sys.stdin.readline()) +q = deque() -    cmd = stdin.readline()[:-1] +    cmd = sys.stdin.readline()[:-1] -        q.append(cmd[7:]) +        q.appendleft(cmd[7:]) -            q.pop(~q[::-1].index(cmd[7:])) +            q.remove(cmd[7:]) +        q.popleft() +    else: -    else: -        bottom += 1 -print((" ".join(q[bottom:][::-1]))) +print((" ".join(q)))