from collections import deque
import sys
input = sys.stdin.readline


class DoublyLinkedList:
    def __init__(self):
        self.doubly_linked_list = deque()

    def insert(self, item):
        self.doubly_linked_list.appendleft(item)

    def delete(self, item):
        if item in self.doubly_linked_list:
            self.doubly_linked_list.remove(item)

    def delete_first(self):
        if self.doubly_linked_list:
            self.doubly_linked_list.popleft()

    def delete_last(self):
        if self.doubly_linked_list:
            self.doubly_linked_list.pop()


doubly_linked_list = DoublyLinkedList()


def command_controller(command, n):
    global doubly_linked_list

    if command == 'insert':
        doubly_linked_list.insert(n)
    if command == 'deleteFirst':
        doubly_linked_list.delete_first()
    if command == 'deleteLast':
        doubly_linked_list.delete_last()
    if command == 'delete':
        doubly_linked_list.delete(n)


n = int(input())
for _ in range(n):
    command = list(input().split())
    command_controller(command[0], command[-1])
print(*doubly_linked_list.doubly_linked_list)
 from collections import deque import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline class DoublyLinkedList:
    def __init__(self):
        self.doubly_linked_list = deque()

    def insert(self, item):
        self.doubly_linked_list.appendleft(item)

    def delete(self, item):
        if item in self.doubly_linked_list:
            self.doubly_linked_list.remove(item)

    def delete_first(self):
        if self.doubly_linked_list:
            self.doubly_linked_list.popleft()

    def delete_last(self):
        if self.doubly_linked_list:
            self.doubly_linked_list.pop() DoublyLinkedList def __init__(self):
        self.doubly_linked_list = deque()

     __init__ self.doubly_linked_list = deque() self.doubly_linked_list self doubly_linked_list deque() deque self self def insert(self, item):
        self.doubly_linked_list.appendleft(item)

     insert self.doubly_linked_list.appendleft(item) self.doubly_linked_list.appendleft self.doubly_linked_list self doubly_linked_list appendleft item self self item item def delete(self, item):
        if item in self.doubly_linked_list:
            self.doubly_linked_list.remove(item)

     delete if item in self.doubly_linked_list:
            self.doubly_linked_list.remove(item)

     item in self.doubly_linked_list item self.doubly_linked_list self doubly_linked_list self.doubly_linked_list.remove(item) self.doubly_linked_list.remove self.doubly_linked_list self doubly_linked_list remove item self self item item def delete_first(self):
        if self.doubly_linked_list:
            self.doubly_linked_list.popleft()

     delete_first if self.doubly_linked_list:
            self.doubly_linked_list.popleft()

     self.doubly_linked_list self doubly_linked_list self.doubly_linked_list.popleft() self.doubly_linked_list.popleft self.doubly_linked_list self doubly_linked_list popleft self self def delete_last(self):
        if self.doubly_linked_list:
            self.doubly_linked_list.pop() delete_last if self.doubly_linked_list:
            self.doubly_linked_list.pop() self.doubly_linked_list self doubly_linked_list self.doubly_linked_list.pop() self.doubly_linked_list.pop self.doubly_linked_list self doubly_linked_list pop self self doubly_linked_list = DoublyLinkedList() doubly_linked_list DoublyLinkedList() DoublyLinkedList def command_controller(command, n):
    global doubly_linked_list

    if command == 'insert':
        doubly_linked_list.insert(n)
    if command == 'deleteFirst':
        doubly_linked_list.delete_first()
    if command == 'deleteLast':
        doubly_linked_list.delete_last()
    if command == 'delete':
        doubly_linked_list.delete(n) command_controller global doubly_linked_list if command == 'insert':
        doubly_linked_list.insert(n)
     command == 'insert' command 'insert' doubly_linked_list.insert(n) doubly_linked_list.insert doubly_linked_list insert n if command == 'deleteFirst':
        doubly_linked_list.delete_first()
     command == 'deleteFirst' command 'deleteFirst' doubly_linked_list.delete_first() doubly_linked_list.delete_first doubly_linked_list delete_first if command == 'deleteLast':
        doubly_linked_list.delete_last()
     command == 'deleteLast' command 'deleteLast' doubly_linked_list.delete_last() doubly_linked_list.delete_last doubly_linked_list delete_last if command == 'delete':
        doubly_linked_list.delete(n) command == 'delete' command 'delete' doubly_linked_list.delete(n) doubly_linked_list.delete doubly_linked_list delete n command command n n n = int(input()) n int(input()) int input() input for _ in range(n):
    command = list(input().split())
    command_controller(command[0], command[-1]) _ range(n) range n command = list(input().split()) command list(input().split()) list input().split() ().split () input split command_controller(command[0], command[-1]) command_controller command[0] command 0 command[-1] command -1 print(*doubly_linked_list.doubly_linked_list) print *doubly_linked_list.doubly_linked_list doubly_linked_list.doubly_linked_list doubly_linked_list doubly_linked_list def command_controller(command, n):
    global doubly_linked_list

    if command == 'insert':
        doubly_linked_list.insert(n)
    if command == 'deleteFirst':
        doubly_linked_list.delete_first()
    if command == 'deleteLast':
        doubly_linked_list.delete_last()
    if command == 'delete':
        doubly_linked_list.delete(n) def command_controller(command, n):
    global doubly_linked_list

    if command == 'insert':
        doubly_linked_list.insert(n)
    if command == 'deleteFirst':
        doubly_linked_list.delete_first()
    if command == 'deleteLast':
        doubly_linked_list.delete_last()
    if command == 'delete':
        doubly_linked_list.delete(n) command_controller n = int(input()) int(input()) n input = sys.stdin.readline sys.stdin.readline input doubly_linked_list = DoublyLinkedList() DoublyLinkedList() doubly_linked_list class DoublyLinkedList:
    def __init__(self):
        self.doubly_linked_list = deque()

    def insert(self, item):
        self.doubly_linked_list.appendleft(item)

    def delete(self, item):
        if item in self.doubly_linked_list:
            self.doubly_linked_list.remove(item)

    def delete_first(self):
        if self.doubly_linked_list:
            self.doubly_linked_list.popleft()

    def delete_last(self):
        if self.doubly_linked_list:
            self.doubly_linked_list.pop() class DoublyLinkedList:
    def __init__(self):
        self.doubly_linked_list = deque()

    def insert(self, item):
        self.doubly_linked_list.appendleft(item)

    def delete(self, item):
        if item in self.doubly_linked_list:
            self.doubly_linked_list.remove(item)

    def delete_first(self):
        if self.doubly_linked_list:
            self.doubly_linked_list.popleft()

    def delete_last(self):
        if self.doubly_linked_list:
            self.doubly_linked_list.pop() DoublyLinkedList command = list(input().split()) list(input().split()) command
from collections import deque
import sys
input = sys.stdin.readline


class DoublyLinkedList:
    def __init__(self):
        self.doubly_linked_list = deque()

    def insert(self, item):
        self.doubly_linked_list.appendleft(item)

    def delete(self, item):
        if item in self.doubly_linked_list:
            self.doubly_linked_list.remove(item)

    def delete_first(self):
        if self.doubly_linked_list:
            self.doubly_linked_list.popleft()

    def delete_last(self):
        if self.doubly_linked_list:
            self.doubly_linked_list.pop()


doubly_linked_list = DoublyLinkedList()


def command_controller(command, n):
    global doubly_linked_list

    if command == 'insert':
        doubly_linked_list.insert(n)
    if command == 'deleteFirst':
        doubly_linked_list.delete_first()
    if command == 'deleteLast':
        doubly_linked_list.delete_last()
    if command == 'delete':
        doubly_linked_list.delete(n)


n = int(input())
for _ in range(n):
    command = list(input().split())
    command_controller(command[0], command[-1])
print(*doubly_linked_list.doubly_linked_list)

