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

from collections import deque

if __name__ == '__main__':
    n = int(input())
    L = deque()

    for _ in range(n):
        command = input().split(" ")
        if command[0] == "insert":
            L.appendleft(command[1])
        elif command[0] == "delete":
            try:
                L.remove(command[1])
            except:
                pass
        elif command[0] == "deleteFirst":
            L.popleft()
        elif command[0] == "deleteLast":
            L.pop()

    print(" ".join(L))
 from collections import deque if __name__ == '__main__':
    n = int(input())
    L = deque()

    for _ in range(n):
        command = input().split(" ")
        if command[0] == "insert":
            L.appendleft(command[1])
        elif command[0] == "delete":
            try:
                L.remove(command[1])
            except:
                pass
        elif command[0] == "deleteFirst":
            L.popleft()
        elif command[0] == "deleteLast":
            L.pop()

    print(" ".join(L)) __name__ == '__main__' __name__ '__main__' n = int(input()) n int(input()) int input() input L = deque() L deque() deque for _ in range(n):
        command = input().split(" ")
        if command[0] == "insert":
            L.appendleft(command[1])
        elif command[0] == "delete":
            try:
                L.remove(command[1])
            except:
                pass
        elif command[0] == "deleteFirst":
            L.popleft()
        elif command[0] == "deleteLast":
            L.pop()

     _ range(n) range n command = input().split(" ") command input().split(" ") ().split () input split " " if command[0] == "insert":
            L.appendleft(command[1])
        elif command[0] == "delete":
            try:
                L.remove(command[1])
            except:
                pass
        elif command[0] == "deleteFirst":
            L.popleft()
        elif command[0] == "deleteLast":
            L.pop()

     command[0] == "insert" command[0] command 0 "insert" L.appendleft(command[1]) L.appendleft L appendleft command[1] command 1 elif command[0] == "delete":
            try:
                L.remove(command[1])
            except:
                pass
         command[0] == "delete" command[0] command 0 "delete" try:
                L.remove(command[1])
            except:
                pass
         except:
                pass
         L.remove(command[1]) L.remove L remove command[1] command 1 elif command[0] == "deleteFirst":
            L.popleft()
         command[0] == "deleteFirst" command[0] command 0 "deleteFirst" L.popleft() L.popleft L popleft elif command[0] == "deleteLast":
            L.pop()

     command[0] == "deleteLast" command[0] command 0 "deleteLast" L.pop() L.pop L pop print(" ".join(L)) print " ".join(L) " ".join " " join L L = deque() deque() L n = int(input()) int(input()) n command = input().split(" ") input().split(" ") command
# -*- coding: utf-8 -*-

from collections import deque

if __name__ == '__main__':
    n = int(input())
    L = deque()

    for _ in range(n):
        command = input().split(" ")
        if command[0] == "insert":
            L.appendleft(command[1])
        elif command[0] == "delete":
            try:
                L.remove(command[1])
            except:
                pass
        elif command[0] == "deleteFirst":
            L.popleft()
        elif command[0] == "deleteLast":
            L.pop()

    print(" ".join(L))

