# -*- coding: utf-8 -*-
from sys import stdin
import collections

class DoublyLinkedList_deque:
    def __init__(self):
        self.doubly_linked_list = collections.deque()

    def execute(self,cmd, key):
        if cmd == 'insert':
            self.doubly_linked_list.appendleft(key)
        elif cmd == 'delete':
            try:
                self.doubly_linked_list.remove(key)
            except:
                pass
        elif cmd == 'deleteFirst':
            self.doubly_linked_list.popleft()
        elif cmd == 'deleteLast':
            self.doubly_linked_list.pop()
        else:
            print("invalid cmd")

n = int(stdin.readline().rstrip())
obj_dll = DoublyLinkedList_deque()
for i in range(n):
    input_str=stdin.readline().rstrip().split()
    cmd = input_str[0]
    x = input_str[1] if len(input_str)>1 else None
    obj_dll.execute(cmd,x)
else:
    print(*obj_dll.doubly_linked_list)
 from sys import stdin import collections collections class DoublyLinkedList_deque:
    def __init__(self):
        self.doubly_linked_list = collections.deque()

    def execute(self,cmd, key):
        if cmd == 'insert':
            self.doubly_linked_list.appendleft(key)
        elif cmd == 'delete':
            try:
                self.doubly_linked_list.remove(key)
            except:
                pass
        elif cmd == 'deleteFirst':
            self.doubly_linked_list.popleft()
        elif cmd == 'deleteLast':
            self.doubly_linked_list.pop()
        else:
            print("invalid cmd") DoublyLinkedList_deque def __init__(self):
        self.doubly_linked_list = collections.deque()

     __init__ self.doubly_linked_list = collections.deque() self.doubly_linked_list self doubly_linked_list collections.deque() collections.deque collections deque self self def execute(self,cmd, key):
        if cmd == 'insert':
            self.doubly_linked_list.appendleft(key)
        elif cmd == 'delete':
            try:
                self.doubly_linked_list.remove(key)
            except:
                pass
        elif cmd == 'deleteFirst':
            self.doubly_linked_list.popleft()
        elif cmd == 'deleteLast':
            self.doubly_linked_list.pop()
        else:
            print("invalid cmd") execute if cmd == 'insert':
            self.doubly_linked_list.appendleft(key)
        elif cmd == 'delete':
            try:
                self.doubly_linked_list.remove(key)
            except:
                pass
        elif cmd == 'deleteFirst':
            self.doubly_linked_list.popleft()
        elif cmd == 'deleteLast':
            self.doubly_linked_list.pop()
        else:
            print("invalid cmd") cmd == 'insert' cmd 'insert' self.doubly_linked_list.appendleft(key) self.doubly_linked_list.appendleft self.doubly_linked_list self doubly_linked_list appendleft key elif cmd == 'delete':
            try:
                self.doubly_linked_list.remove(key)
            except:
                pass
         cmd == 'delete' cmd 'delete' try:
                self.doubly_linked_list.remove(key)
            except:
                pass
         except:
                pass
         self.doubly_linked_list.remove(key) self.doubly_linked_list.remove self.doubly_linked_list self doubly_linked_list remove key elif cmd == 'deleteFirst':
            self.doubly_linked_list.popleft()
         cmd == 'deleteFirst' cmd 'deleteFirst' self.doubly_linked_list.popleft() self.doubly_linked_list.popleft self.doubly_linked_list self doubly_linked_list popleft elif cmd == 'deleteLast':
            self.doubly_linked_list.pop()
         cmd == 'deleteLast' cmd 'deleteLast' self.doubly_linked_list.pop() self.doubly_linked_list.pop self.doubly_linked_list self doubly_linked_list pop print("invalid cmd") print "invalid cmd" self self cmd cmd key key n = int(stdin.readline().rstrip()) n int(stdin.readline().rstrip()) int stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip obj_dll = DoublyLinkedList_deque() obj_dll DoublyLinkedList_deque() DoublyLinkedList_deque for i in range(n):
    input_str=stdin.readline().rstrip().split()
    cmd = input_str[0]
    x = input_str[1] if len(input_str)>1 else None
    obj_dll.execute(cmd,x)
else:
    print(*obj_dll.doubly_linked_list) i range(n) range n input_str=stdin.readline().rstrip().split() input_str stdin.readline().rstrip().split() stdin.readline().rstrip().split stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip split cmd = input_str[0] cmd input_str[0] input_str 0 x = input_str[1] if len(input_str)>1 else None x input_str[1] if len(input_str)>1 else None len(input_str)>1 len(input_str) len input_str 1 input_str[1] input_str 1 None obj_dll.execute(cmd,x) obj_dll.execute obj_dll execute cmd x print(*obj_dll.doubly_linked_list) print *obj_dll.doubly_linked_list obj_dll.doubly_linked_list obj_dll doubly_linked_list obj_dll = DoublyLinkedList_deque() DoublyLinkedList_deque() obj_dll x = input_str[1] if len(input_str)>1 else None input_str[1] if len(input_str)>1 else None x input_str=stdin.readline().rstrip().split() stdin.readline().rstrip().split() input_str n = int(stdin.readline().rstrip()) int(stdin.readline().rstrip()) n class DoublyLinkedList_deque:
    def __init__(self):
        self.doubly_linked_list = collections.deque()

    def execute(self,cmd, key):
        if cmd == 'insert':
            self.doubly_linked_list.appendleft(key)
        elif cmd == 'delete':
            try:
                self.doubly_linked_list.remove(key)
            except:
                pass
        elif cmd == 'deleteFirst':
            self.doubly_linked_list.popleft()
        elif cmd == 'deleteLast':
            self.doubly_linked_list.pop()
        else:
            print("invalid cmd") class DoublyLinkedList_deque:
    def __init__(self):
        self.doubly_linked_list = collections.deque()

    def execute(self,cmd, key):
        if cmd == 'insert':
            self.doubly_linked_list.appendleft(key)
        elif cmd == 'delete':
            try:
                self.doubly_linked_list.remove(key)
            except:
                pass
        elif cmd == 'deleteFirst':
            self.doubly_linked_list.popleft()
        elif cmd == 'deleteLast':
            self.doubly_linked_list.pop()
        else:
            print("invalid cmd") DoublyLinkedList_deque cmd = input_str[0] input_str[0] cmd
# -*- coding: utf-8 -*-
from sys import stdin
import collections

class DoublyLinkedList_deque:
    def __init__(self):
        self.doubly_linked_list = collections.deque()

    def execute(self,cmd, key):
        if cmd == 'insert':
            self.doubly_linked_list.appendleft(key)
        elif cmd == 'delete':
            try:
                self.doubly_linked_list.remove(key)
            except:
                pass
        elif cmd == 'deleteFirst':
            self.doubly_linked_list.popleft()
        elif cmd == 'deleteLast':
            self.doubly_linked_list.pop()
        else:
            print("invalid cmd")

n = int(stdin.readline().rstrip())
obj_dll = DoublyLinkedList_deque()
for i in range(n):
    input_str=stdin.readline().rstrip().split()
    cmd = input_str[0]
    x = input_str[1] if len(input_str)>1 else None
    obj_dll.execute(cmd,x)
else:
    print(*obj_dll.doubly_linked_list)

