### BUGGY CODE ###

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

class Node(object):
    """Node class
    """

    def __init__(self, key=None, previous_node=None, next_node=None):
        """Constructor
        """
        self.key = key
        ''' key '''

        self.previous_node = previous_node
        ''' previous node '''

        self.next_node = next_node
        ''' next node '''

    def copy_from(self, node):
        self.key = node.key
        self.previous_node = node.previous_node
        self.next_node = node.next_node

    def print_on(self):
        print self.key, 


class DoublyLinkedList(object):
    """Doubly Linked List Class
    """

    def __init__(self, sentinel_key=-1):
        """Constructor(make sentinel node)
        """
        self.sentinel_node = Node(key=sentinel_key)
        self.sentinel_node.next_node = self.sentinel_node
        self.sentinel_node.previous_node = self.sentinel_node

    def insert_node(self, key):
        """insert node which has specified key at first position"""
        
        new_node = Node(key=key, previous_node=self.sentinel_node, next_node=self.sentinel_node.next_node) 
        self.sentinel_node.next_node.previous_node = new_node
        self.sentinel_node.next_node = new_node
              
    def delete_first(self):
        """ delete first node """
        if self.sentinel_node.next_node.key != -1:
            self.sentinel_node.next_node = self.sentinel_node.next_node.next_node
            self.sentinel_node.next_node.previous_node = self.sentinel_node

    def delete_last(self):
        """delete last node """
        if self.sentinel_node.next_node.key != -1:
            self.sentinel_node.previous_node = self.sentinel_node.previous_node.previous_node
            self.sentinel_node.previous_node.next_node = self.sentinel_node
 
    def delete(self, key=None):
        """ delete node which has a key 'key' """
        target_node = self.sentinel_node.next_node
        while target_node.key is not -1:
            if target_node.key == key:
                target_node.previous_node.next_node = target_node.next_node
                target_node.next_node.previous_node = target_node.previous_node
                break
            target_node = target_node.next_node
 
    def print_on(self):
        target_node = self.sentinel_node
        while target_node.next_node is not self.sentinel_node:
            target_node = target_node.next_node
            target_node.print_on()
            

def main():
    doubly_linked_list = DoublyLinkedList()

    input_length = int(raw_input())
    counter = 0
    while counter < input_length:
        counter += 1
        input_line = raw_input()
        if input_line[0] == 'i':
            doubly_linked_list.insert_node(input_line[7:])
        elif input_line[6] == 'F':
            doubly_linked_list.delete_first()
        elif input_line[6] == 'L':
            doubly_linked_list.delete_last()
        else:
            doubly_linked_list.delete(input_line[7:])

    doubly_linked_list.print_on()


if __name__ == '__main__':
    main()

### FIXED CODE ###

# tameshi 
n = input()
lis = []
ans = 0
for i in xrange(n):
    com = raw_input()
    if   com[0] == 'i':
        lis.append(com[7:])
    elif com[6] == ' ':
        try:
            lis.pop(~lis[::-1].index(com[7:]))
        except:
            pass
    elif com[6] == 'F':
        lis.pop()
    else:ans += 1
  
print ' '.join( map(str, reversed(lis[ans:])) )