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

import collections


def process(commands):
    queue = collections.deque()
    for c in commands:
        if "insert" in c:
            queue.appendleft(int(c[7:]))
        elif "deleteFirst" in c:
            try:
                _ = queue.popleft()
            except IndexError as e:
                pass
        elif "deleteLast" in c:
            try:
                _ = queue.pop()
            except IndexError as e:
                pass
        elif "delete" in c:
            try:
                queue.remove(int(c[7:]))
            except ValueError as e:
                pass
    print(" ".join(list(map(str, queue))))


def main():
    n = int(input())
    process([input() for i in range(n)])


if __name__ == "__main__":
    main() import collections collections def process(commands):
    queue = collections.deque()
    for c in commands:
        if "insert" in c:
            queue.appendleft(int(c[7:]))
        elif "deleteFirst" in c:
            try:
                _ = queue.popleft()
            except IndexError as e:
                pass
        elif "deleteLast" in c:
            try:
                _ = queue.pop()
            except IndexError as e:
                pass
        elif "delete" in c:
            try:
                queue.remove(int(c[7:]))
            except ValueError as e:
                pass
    print(" ".join(list(map(str, queue)))) process queue = collections.deque() queue collections.deque() collections.deque collections deque for c in commands:
        if "insert" in c:
            queue.appendleft(int(c[7:]))
        elif "deleteFirst" in c:
            try:
                _ = queue.popleft()
            except IndexError as e:
                pass
        elif "deleteLast" in c:
            try:
                _ = queue.pop()
            except IndexError as e:
                pass
        elif "delete" in c:
            try:
                queue.remove(int(c[7:]))
            except ValueError as e:
                pass
     c commands if "insert" in c:
            queue.appendleft(int(c[7:]))
        elif "deleteFirst" in c:
            try:
                _ = queue.popleft()
            except IndexError as e:
                pass
        elif "deleteLast" in c:
            try:
                _ = queue.pop()
            except IndexError as e:
                pass
        elif "delete" in c:
            try:
                queue.remove(int(c[7:]))
            except ValueError as e:
                pass
     "insert" in c "insert" c queue.appendleft(int(c[7:])) queue.appendleft queue appendleft int(c[7:]) int c[7:] c 7: 7 elif "deleteFirst" in c:
            try:
                _ = queue.popleft()
            except IndexError as e:
                pass
         "deleteFirst" in c "deleteFirst" c try:
                _ = queue.popleft()
            except IndexError as e:
                pass
         except IndexError as e:
                pass
         _ = queue.popleft() _ queue.popleft() queue.popleft queue popleft elif "deleteLast" in c:
            try:
                _ = queue.pop()
            except IndexError as e:
                pass
         "deleteLast" in c "deleteLast" c try:
                _ = queue.pop()
            except IndexError as e:
                pass
         except IndexError as e:
                pass
         _ = queue.pop() _ queue.pop() queue.pop queue pop elif "delete" in c:
            try:
                queue.remove(int(c[7:]))
            except ValueError as e:
                pass
     "delete" in c "delete" c try:
                queue.remove(int(c[7:]))
            except ValueError as e:
                pass
     except ValueError as e:
                pass
     queue.remove(int(c[7:])) queue.remove queue remove int(c[7:]) int c[7:] c 7: 7 print(" ".join(list(map(str, queue)))) print " ".join(list(map(str, queue))) " ".join " " join list(map(str, queue)) list map(str, queue) map str queue commands commands def main():
    n = int(input())
    process([input() for i in range(n)]) main n = int(input()) n int(input()) int input() input input() for i in range(n) for i in range(n) i range(n) range n for i in range(n) input() input process([input() for i in range(n)]) process [input() for i in range(n)] if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n = int(input())
    process([input() for i in range(n)]) def main():
    n = int(input())
    process([input() for i in range(n)]) main def process(commands):
    queue = collections.deque()
    for c in commands:
        if "insert" in c:
            queue.appendleft(int(c[7:]))
        elif "deleteFirst" in c:
            try:
                _ = queue.popleft()
            except IndexError as e:
                pass
        elif "deleteLast" in c:
            try:
                _ = queue.pop()
            except IndexError as e:
                pass
        elif "delete" in c:
            try:
                queue.remove(int(c[7:]))
            except ValueError as e:
                pass
    print(" ".join(list(map(str, queue)))) def process(commands):
    queue = collections.deque()
    for c in commands:
        if "insert" in c:
            queue.appendleft(int(c[7:]))
        elif "deleteFirst" in c:
            try:
                _ = queue.popleft()
            except IndexError as e:
                pass
        elif "deleteLast" in c:
            try:
                _ = queue.pop()
            except IndexError as e:
                pass
        elif "delete" in c:
            try:
                queue.remove(int(c[7:]))
            except ValueError as e:
                pass
    print(" ".join(list(map(str, queue)))) process
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import collections


def process(commands):
    queue = collections.deque()
    for c in commands:
        if "insert" in c:
            queue.appendleft(int(c[7:]))
        elif "deleteFirst" in c:
            try:
                _ = queue.popleft()
            except IndexError as e:
                pass
        elif "deleteLast" in c:
            try:
                _ = queue.pop()
            except IndexError as e:
                pass
        elif "delete" in c:
            try:
                queue.remove(int(c[7:]))
            except ValueError as e:
                pass
    print(" ".join(list(map(str, queue))))


def main():
    n = int(input())
    process([input() for i in range(n)])


if __name__ == "__main__":
    main()