### BUGGY CODE ###

class MyList(object):
    def __init__(self, value=None, pre=None, _next=None, _tail=None):
        self._value = value
        self._pre = pre
        self._next = _next
        if _tail is None:
            self._tail = self
        else:
            self._tail = _tail

    def insert(self, value):
        _next = self._next
        self._next = MyList(value, self, _next, self._tail)
        if _next is not None:
            _next._pre = self._next
        else:
            self._tail = self._next

    def delete(self, value):
        current = self._next
        while current is not None:
            if current._value == value:
                current._pre._next = current._next
                if current._next is not None:
                    current._next._pre = current._pre
                else:
                    self._tail = current._pre
                break
            current = current._next

    def delete_first(self):
        first = self._next
        if first is not None:
            if first._next is not None:
                first._next._pre = self
            else:
                self._tail = self
            self._next = first._next

    def delete_last(self):
        tail = self._tail
        if tail._pre is not None:
            tail._pre._next = None
            self._tail = tail._pre

    def toList(self):
        current = self._next
        lst = []
        while current is not None:
            lst.append(current._value)
            current = current._next
        return lst


def doubly_inked_list(commands):
    lst = MyList()
    for command in commands:
        if command[0] == "insert":
            lst.insert(command[1])
        elif command[0] == "delete":
            lst.delete(command[1])
        elif command[0] == "deleteFirst":
            lst.delete_first()
        elif command[0] == "deleteLast":
            lst.delete_last()
        else:
            raise ValueError
    return lst.toList()


if __name__ == "__main__":
    n = int(input())
    commands = [input().split() for i in range(0, n)]
    print(" ".join(doubly_inked_list(commands)))

### FIXED CODE ###

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


class Cell(object):
    __slots__ = ["value", "pre", "next"]

    def __init__(self, value=None, pre=None, _next=None):
        if pre is None and _next is None:
            self.value = None
            self.pre = self
            self.next = self
        else:
            self.value = value
            self.pre = pre
            self.next = _next


class MyList(object):
    def __init__(self):
        self._nil = Cell()

    def insert(self, value):
        self._nil.next = Cell(value, self._nil, self._nil.next)
        self._nil.next.next.pre = self._nil.next

    def delete(self, value):
        self._delete_to(self._search(value))

    def delete_first(self):
        self._delete_to(self._nil.next)

    def delete_last(self):
        self._delete_to(self._nil.pre)

    def toList(self):
        gen = self._val_generator()
        return [val for val in gen()]

    def _val_generator(self):
        def gen():
            current = self._nil.next
            while current is not self._nil:
                yield current.value
                current = current.next
        return gen

    def _delete_to(self, cell):
        if cell is not self._nil:
            cell.next.pre = cell.pre
            cell.pre.next = cell.next

    def _search(self, value):
        current = self._nil.next
        while current is not self._nil and current.value != value:
            current = current.next
        return current


def doubly_inked_list(commands):
    lst = MyList()
    for command in commands:
        if command[0] == "insert":
            lst.insert(command[1])
        elif command[0] == "delete":
            lst.delete(command[1])
        elif command[0] == "deleteFirst":
            lst.delete_first()
        elif command[0] == "deleteLast":
            lst.delete_last()
        else:
            raise ValueError
    return lst.toList()


if __name__ == "__main__":
    commands = [val.split() for val in sys.stdin.read().splitlines()]
    pop = commands.pop(0)
    print(" ".join(doubly_inked_list(commands)))