### BUGGY CODE ###

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

    def insert(self, value):
        _next = self._next
        self._next = MyList(value, self, _next)
        if _next is not None:
            _next._pre = 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
                break
            current = current._next

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

    def delete_last(self):
        current = self
        while current._next is not None:
            current = current._next
        if current._pre is not None:
            current._pre._next = None

    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)))