from collections import deque


def main():
    n = int(input())
    Q = deque()

    for _ in range(n):
        cmd = input().split()

        if cmd[0] == "deleteFirst":
            Q.popleft()
        elif cmd[0] == "deleteLast":
            Q.pop()
        elif cmd[0] == "insert":
            Q.appendleft(int(cmd[1]))
        elif cmd[0] == "delete" and int(cmd[1]) in Q:
            Q.remove(int(cmd[1]))

    print(*Q)


if __name__ == "__main__":
    main()
 from collections import deque def main():
    n = int(input())
    Q = deque()

    for _ in range(n):
        cmd = input().split()

        if cmd[0] == "deleteFirst":
            Q.popleft()
        elif cmd[0] == "deleteLast":
            Q.pop()
        elif cmd[0] == "insert":
            Q.appendleft(int(cmd[1]))
        elif cmd[0] == "delete" and int(cmd[1]) in Q:
            Q.remove(int(cmd[1]))

    print(*Q) main n = int(input()) n int(input()) int input() input Q = deque() Q deque() deque for _ in range(n):
        cmd = input().split()

        if cmd[0] == "deleteFirst":
            Q.popleft()
        elif cmd[0] == "deleteLast":
            Q.pop()
        elif cmd[0] == "insert":
            Q.appendleft(int(cmd[1]))
        elif cmd[0] == "delete" and int(cmd[1]) in Q:
            Q.remove(int(cmd[1]))

     _ range(n) range n cmd = input().split() cmd input().split() ().split () input split if cmd[0] == "deleteFirst":
            Q.popleft()
        elif cmd[0] == "deleteLast":
            Q.pop()
        elif cmd[0] == "insert":
            Q.appendleft(int(cmd[1]))
        elif cmd[0] == "delete" and int(cmd[1]) in Q:
            Q.remove(int(cmd[1]))

     cmd[0] == "deleteFirst" cmd[0] cmd 0 "deleteFirst" Q.popleft() Q.popleft Q popleft elif cmd[0] == "deleteLast":
            Q.pop()
         cmd[0] == "deleteLast" cmd[0] cmd 0 "deleteLast" Q.pop() Q.pop Q pop elif cmd[0] == "insert":
            Q.appendleft(int(cmd[1]))
         cmd[0] == "insert" cmd[0] cmd 0 "insert" Q.appendleft(int(cmd[1])) Q.appendleft Q appendleft int(cmd[1]) int cmd[1] cmd 1 elif cmd[0] == "delete" and int(cmd[1]) in Q:
            Q.remove(int(cmd[1]))

     cmd[0] == "delete" and int(cmd[1]) in Q cmd[0] == "delete" cmd[0] cmd 0 "delete" int(cmd[1]) in Q int(cmd[1]) int cmd[1] cmd 1 Q Q.remove(int(cmd[1])) Q.remove Q remove int(cmd[1]) int cmd[1] cmd 1 print(*Q) print *Q Q if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n = int(input())
    Q = deque()

    for _ in range(n):
        cmd = input().split()

        if cmd[0] == "deleteFirst":
            Q.popleft()
        elif cmd[0] == "deleteLast":
            Q.pop()
        elif cmd[0] == "insert":
            Q.appendleft(int(cmd[1]))
        elif cmd[0] == "delete" and int(cmd[1]) in Q:
            Q.remove(int(cmd[1]))

    print(*Q) def main():
    n = int(input())
    Q = deque()

    for _ in range(n):
        cmd = input().split()

        if cmd[0] == "deleteFirst":
            Q.popleft()
        elif cmd[0] == "deleteLast":
            Q.pop()
        elif cmd[0] == "insert":
            Q.appendleft(int(cmd[1]))
        elif cmd[0] == "delete" and int(cmd[1]) in Q:
            Q.remove(int(cmd[1]))

    print(*Q) main
from collections import deque


def main():
    n = int(input())
    Q = deque()

    for _ in range(n):
        cmd = input().split()

        if cmd[0] == "deleteFirst":
            Q.popleft()
        elif cmd[0] == "deleteLast":
            Q.pop()
        elif cmd[0] == "insert":
            Q.appendleft(int(cmd[1]))
        elif cmd[0] == "delete" and int(cmd[1]) in Q:
            Q.remove(int(cmd[1]))

    print(*Q)


if __name__ == "__main__":
    main()

