# -*- coding:utf-8 -*-

import collections

n = int(eval(input()))

command = [input().split() for i in range(n)]

ans = collections.deque()



for i in range(n):

    if command[i][0] == "insert":

        ans.appendleft(command[i][1])

    elif ans == []:

        continue

    elif command[i][0] == "delete":

        try:

            ans.remove(command[i][1])

        except:

            continue

    elif command[i][0] == "deleteFirst":

        ans.popleft()

    else:

        ans.pop()



print((' '.join(ans)))
# -*- coding:utf-8 -*-

import collections

n = int(eval(input()))

ans = collections.deque()



for i in range(n):

    command = input().split()

    if command[0] == "insert":

        ans.appendleft(command[1])

    elif ans == []:

        continue

    elif command[0] == "delete":

        try:

            ans.remove(command[1])

        except:

            pass

    elif command[0] == "deleteFirst":

        ans.popleft()

    else:

        ans.pop()



print((' '.join(ans)))
# -*- coding:utf-8 -*-
import collections

n = int(eval(input()))
command = [input().split() for i in range(n)]
ans = collections.deque()
for i in range(n):
    if command[i][0] == "insert":
        ans.appendleft(command[i][1])
    elif ans == []:
        continue
    elif command[i][0] == "delete":
        try:
            ans.remove(command[i][1])
        except:
            continue
    elif command[i][0] == "deleteFirst":
        ans.popleft()
    else:
        ans.pop()
print((" ".join(ans)))

# -*- coding:utf-8 -*-
import collections

n = int(eval(input()))
ans = collections.deque()
for i in range(n):
    command = input().split()
    if command[0] == "insert":
        ans.appendleft(command[1])
    elif ans == []:
        continue
    elif command[0] == "delete":
        try:
            ans.remove(command[1])
        except:
            pass
    elif command[0] == "deleteFirst":
        ans.popleft()
    else:
        ans.pop()
print((" ".join(ans)))

-command = [input().split() for i in range(n)] -    if command[i][0] == "insert": -        ans.appendleft(command[i][1]) +    command = input().split() +    if command[0] == "insert": +        ans.appendleft(command[1]) -    elif command[i][0] == "delete": +    elif command[0] == "delete": -            ans.remove(command[i][1]) +            ans.remove(command[1]) -            continue -    elif command[i][0] == "deleteFirst": +            pass +    elif command[0] == "deleteFirst":