
from collections import deque

n = int(input())
linked_list = deque([])

for i in range(n):
    line = input().split()
    cmd = line[0]

    if len(line) == 2:
        value = line[1]

    if cmd == "insert":
        linked_list.appendleft(value)
    elif cmd == "delete":
        if value in linked_list:
            linked_list.remove(value)
    elif cmd == "deleteFirst":
        linked_list.popleft()
    elif cmd == "deleteLast":
        linked_list.pop()

print(*linked_list) from collections import deque n = int(input()) n int(input()) int input() input linked_list = deque([]) linked_list deque([]) deque [] for i in range(n):
    line = input().split()
    cmd = line[0]

    if len(line) == 2:
        value = line[1]

    if cmd == "insert":
        linked_list.appendleft(value)
    elif cmd == "delete":
        if value in linked_list:
            linked_list.remove(value)
    elif cmd == "deleteFirst":
        linked_list.popleft()
    elif cmd == "deleteLast":
        linked_list.pop() i range(n) range n line = input().split() line input().split() ().split () input split cmd = line[0] cmd line[0] line 0 if len(line) == 2:
        value = line[1]

     len(line) == 2 len(line) len line 2 value = line[1] value line[1] line 1 if cmd == "insert":
        linked_list.appendleft(value)
    elif cmd == "delete":
        if value in linked_list:
            linked_list.remove(value)
    elif cmd == "deleteFirst":
        linked_list.popleft()
    elif cmd == "deleteLast":
        linked_list.pop() cmd == "insert" cmd "insert" linked_list.appendleft(value) linked_list.appendleft linked_list appendleft value elif cmd == "delete":
        if value in linked_list:
            linked_list.remove(value)
     cmd == "delete" cmd "delete" if value in linked_list:
            linked_list.remove(value)
     value in linked_list value linked_list linked_list.remove(value) linked_list.remove linked_list remove value elif cmd == "deleteFirst":
        linked_list.popleft()
     cmd == "deleteFirst" cmd "deleteFirst" linked_list.popleft() linked_list.popleft linked_list popleft elif cmd == "deleteLast":
        linked_list.pop() cmd == "deleteLast" cmd "deleteLast" linked_list.pop() linked_list.pop linked_list pop print(*linked_list) print *linked_list linked_list linked_list = deque([]) deque([]) linked_list cmd = line[0] line[0] cmd line = input().split() input().split() line value = line[1] line[1] value n = int(input()) int(input()) n

from collections import deque

n = int(input())
linked_list = deque([])

for i in range(n):
    line = input().split()
    cmd = line[0]

    if len(line) == 2:
        value = line[1]

    if cmd == "insert":
        linked_list.appendleft(value)
    elif cmd == "delete":
        if value in linked_list:
            linked_list.remove(value)
    elif cmd == "deleteFirst":
        linked_list.popleft()
    elif cmd == "deleteLast":
        linked_list.pop()

print(*linked_list)