#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ???????????£???????????? '''

from collections import deque

functions = {"insert": lambda obj, x: obj.insert(x),
             "delete": lambda obj, x: obj.delete(x),
             "deleteFirst": lambda obj: obj.deleteFirst(),
             "deleteLast": lambda obj: obj.deleteLast()}


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

    def __init__(self):
        # self.list = []
        self.list = deque()

    def insert(self, x):
        """ ???????????????x?????????????´?????????\ """
        # self.list = [x] + self.list
        self.list.appendleft(x)

    def delete(self, x):
        """ ??????x??????????????????????´?????????? """
        # for i in range(len(self.list)):
        #     if self.list[i] == x:
        #         self.list.pop(i)
        #         break
        if x in self.list:
            self.list.remove(x)

    def deleteFirst(self):
        """ ?????????????????????????´?????????? """
        # self.list.pop(0)
        self.list.popleft()

    def deleteLast(self):
        """ ????????????????°????????´?????????? """
        self.list.pop()


if __name__ == '__main__':
    N = int(input())

    q = deque()
    for i in range(N):
        command = input().split()
        if command[0] == 'insert':
            q.appendleft(command[1])
        elif command[0] == 'delete':
            if command[1] in q:
                q.remove(command[1])
        elif command[0] == 'deleteFirst':
            q.popleft()
        elif command[0] == 'deleteLast':
            q.pop()

    print(' '.join(map(str, q)))

    # dll = DoublyLinkedList()
    # for i in range(N):
    #     command = input().split()
    #     if len(command) == 1:
    #         functions[command[0]](dll)
    #     elif len(command) == 2:
    #         functions[command[0]](dll, int(command[1]))
    # print(' '.join(map(str, dll.list))) ''' ???????????£???????????? ''' from collections import deque functions = {"insert": lambda obj, x: obj.insert(x),
             "delete": lambda obj, x: obj.delete(x),
             "deleteFirst": lambda obj: obj.deleteFirst(),
             "deleteLast": lambda obj: obj.deleteLast()} functions {"insert": lambda obj, x: obj.insert(x),
             "delete": lambda obj, x: obj.delete(x),
             "deleteFirst": lambda obj: obj.deleteFirst(),
             "deleteLast": lambda obj: obj.deleteLast()} "insert" "insert" lambda obj, x: obj.insert(x) obj.insert(x) obj.insert obj insert x obj x "delete" "delete" lambda obj, x: obj.delete(x) obj.delete(x) obj.delete obj delete x obj x "deleteFirst" "deleteFirst" lambda obj: obj.deleteFirst() obj.deleteFirst() obj.deleteFirst obj deleteFirst obj "deleteLast" "deleteLast" lambda obj: obj.deleteLast() obj.deleteLast() obj.deleteLast obj deleteLast obj class DoublyLinkedList(object):
    """ Doubly Linked List """

    def __init__(self):
        # self.list = []
        self.list = deque()

    def insert(self, x):
        """ ???????????????x?????????????´?????????\ """
        # self.list = [x] + self.list
        self.list.appendleft(x)

    def delete(self, x):
        """ ??????x??????????????????????´?????????? """
        # for i in range(len(self.list)):
        #     if self.list[i] == x:
        #         self.list.pop(i)
        #         break
        if x in self.list:
            self.list.remove(x)

    def deleteFirst(self):
        """ ?????????????????????????´?????????? """
        # self.list.pop(0)
        self.list.popleft()

    def deleteLast(self):
        """ ????????????????°????????´?????????? """
        self.list.pop() DoublyLinkedList """ Doubly Linked List """ def __init__(self):
        # self.list = []
        self.list = deque()

     __init__ self.list = deque() self.list self list deque() deque self self def insert(self, x):
        """ ???????????????x?????????????´?????????\ """
        # self.list = [x] + self.list
        self.list.appendleft(x)

     insert """ ???????????????x?????????????´?????????\ """ self.list.appendleft(x) self.list.appendleft self.list self list appendleft x self self x x def delete(self, x):
        """ ??????x??????????????????????´?????????? """
        # for i in range(len(self.list)):
        #     if self.list[i] == x:
        #         self.list.pop(i)
        #         break
        if x in self.list:
            self.list.remove(x)

     delete """ ??????x??????????????????????´?????????? """ if x in self.list:
            self.list.remove(x)

     x in self.list x self.list self list self.list.remove(x) self.list.remove self.list self list remove x self self x x def deleteFirst(self):
        """ ?????????????????????????´?????????? """
        # self.list.pop(0)
        self.list.popleft()

     deleteFirst """ ?????????????????????????´?????????? """ self.list.popleft() self.list.popleft self.list self list popleft self self def deleteLast(self):
        """ ????????????????°????????´?????????? """
        self.list.pop() deleteLast """ ????????????????°????????´?????????? """ self.list.pop() self.list.pop self.list self list pop self self object if __name__ == '__main__':
    N = int(input())

    q = deque()
    for i in range(N):
        command = input().split()
        if command[0] == 'insert':
            q.appendleft(command[1])
        elif command[0] == 'delete':
            if command[1] in q:
                q.remove(command[1])
        elif command[0] == 'deleteFirst':
            q.popleft()
        elif command[0] == 'deleteLast':
            q.pop()

    print(' '.join(map(str, q)))

    # dll = DoublyLinkedList()
    # for i in range(N):
    #     command = input().split()
    #     if len(command) == 1:
    #         functions[command[0]](dll)
    #     elif len(command) == 2:
    #         functions[command[0]](dll, int(command[1]))
    # print(' '.join(map(str, dll.list))) __name__ == '__main__' __name__ '__main__' N = int(input()) N int(input()) int input() input q = deque() q deque() deque for i in range(N):
        command = input().split()
        if command[0] == 'insert':
            q.appendleft(command[1])
        elif command[0] == 'delete':
            if command[1] in q:
                q.remove(command[1])
        elif command[0] == 'deleteFirst':
            q.popleft()
        elif command[0] == 'deleteLast':
            q.pop()

     i range(N) range N command = input().split() command input().split() ().split () input split if command[0] == 'insert':
            q.appendleft(command[1])
        elif command[0] == 'delete':
            if command[1] in q:
                q.remove(command[1])
        elif command[0] == 'deleteFirst':
            q.popleft()
        elif command[0] == 'deleteLast':
            q.pop()

     command[0] == 'insert' command[0] command 0 'insert' q.appendleft(command[1]) q.appendleft q appendleft command[1] command 1 elif command[0] == 'delete':
            if command[1] in q:
                q.remove(command[1])
         command[0] == 'delete' command[0] command 0 'delete' if command[1] in q:
                q.remove(command[1])
         command[1] in q command[1] command 1 q q.remove(command[1]) q.remove q remove command[1] command 1 elif command[0] == 'deleteFirst':
            q.popleft()
         command[0] == 'deleteFirst' command[0] command 0 'deleteFirst' q.popleft() q.popleft q popleft elif command[0] == 'deleteLast':
            q.pop()

     command[0] == 'deleteLast' command[0] command 0 'deleteLast' q.pop() q.pop q pop print(' '.join(map(str, q))) print ' '.join(map(str, q)) ' '.join ' ' join map(str, q) map str q q = deque() deque() q command = input().split() input().split() command class DoublyLinkedList(object):
    """ Doubly Linked List """

    def __init__(self):
        # self.list = []
        self.list = deque()

    def insert(self, x):
        """ ???????????????x?????????????´?????????\ """
        # self.list = [x] + self.list
        self.list.appendleft(x)

    def delete(self, x):
        """ ??????x??????????????????????´?????????? """
        # for i in range(len(self.list)):
        #     if self.list[i] == x:
        #         self.list.pop(i)
        #         break
        if x in self.list:
            self.list.remove(x)

    def deleteFirst(self):
        """ ?????????????????????????´?????????? """
        # self.list.pop(0)
        self.list.popleft()

    def deleteLast(self):
        """ ????????????????°????????´?????????? """
        self.list.pop() class DoublyLinkedList(object):
    """ Doubly Linked List """

    def __init__(self):
        # self.list = []
        self.list = deque()

    def insert(self, x):
        """ ???????????????x?????????????´?????????\ """
        # self.list = [x] + self.list
        self.list.appendleft(x)

    def delete(self, x):
        """ ??????x??????????????????????´?????????? """
        # for i in range(len(self.list)):
        #     if self.list[i] == x:
        #         self.list.pop(i)
        #         break
        if x in self.list:
            self.list.remove(x)

    def deleteFirst(self):
        """ ?????????????????????????´?????????? """
        # self.list.pop(0)
        self.list.popleft()

    def deleteLast(self):
        """ ????????????????°????????´?????????? """
        self.list.pop() DoublyLinkedList N = int(input()) int(input()) N functions = {"insert": lambda obj, x: obj.insert(x),
             "delete": lambda obj, x: obj.delete(x),
             "deleteFirst": lambda obj: obj.deleteFirst(),
             "deleteLast": lambda obj: obj.deleteLast()} {"insert": lambda obj, x: obj.insert(x),
             "delete": lambda obj, x: obj.delete(x),
             "deleteFirst": lambda obj: obj.deleteFirst(),
             "deleteLast": lambda obj: obj.deleteLast()} functions
#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ???????????£???????????? '''

from collections import deque

functions = {"insert": lambda obj, x: obj.insert(x),
             "delete": lambda obj, x: obj.delete(x),
             "deleteFirst": lambda obj: obj.deleteFirst(),
             "deleteLast": lambda obj: obj.deleteLast()}


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

    def __init__(self):
        # self.list = []
        self.list = deque()

    def insert(self, x):
        """ ???????????????x?????????????´?????????\ """
        # self.list = [x] + self.list
        self.list.appendleft(x)

    def delete(self, x):
        """ ??????x??????????????????????´?????????? """
        # for i in range(len(self.list)):
        #     if self.list[i] == x:
        #         self.list.pop(i)
        #         break
        if x in self.list:
            self.list.remove(x)

    def deleteFirst(self):
        """ ?????????????????????????´?????????? """
        # self.list.pop(0)
        self.list.popleft()

    def deleteLast(self):
        """ ????????????????°????????´?????????? """
        self.list.pop()


if __name__ == '__main__':
    N = int(input())

    q = deque()
    for i in range(N):
        command = input().split()
        if command[0] == 'insert':
            q.appendleft(command[1])
        elif command[0] == 'delete':
            if command[1] in q:
                q.remove(command[1])
        elif command[0] == 'deleteFirst':
            q.popleft()
        elif command[0] == 'deleteLast':
            q.pop()

    print(' '.join(map(str, q)))

    # dll = DoublyLinkedList()
    # for i in range(N):
    #     command = input().split()
    #     if len(command) == 1:
    #         functions[command[0]](dll)
    #     elif len(command) == 2:
    #         functions[command[0]](dll, int(command[1]))
    # print(' '.join(map(str, dll.list)))