from collections import deque


def print_list(que):
    for i, q in enumerate(que):
        if i != len(que)-1:
            print(q, end=' ')
        else:
            print(q)


def main():
    List = deque()
    n = int(input())
    for i in range(n):
        order = input().split()
        if order[0] == "insert":
            List.appendleft(order[1])
        elif order[0] == "delete":
            try:
                List.remove(order[1])
            except ValueError:
                pass
        elif order[0] == "deleteFirst":
            List.popleft()
        elif order[0] == "deleteLast":
            List.pop()
    print_list(List)


if __name__ == "__main__":
    main()
 from collections import deque def print_list(que):
    for i, q in enumerate(que):
        if i != len(que)-1:
            print(q, end=' ')
        else:
            print(q) print_list for i, q in enumerate(que):
        if i != len(que)-1:
            print(q, end=' ')
        else:
            print(q) i q enumerate(que) enumerate que if i != len(que)-1:
            print(q, end=' ')
        else:
            print(q) i != len(que)-1 i len(que)-1 len(que) len que 1 print(q, end=' ') print q end=' ' end ' ' print(q) print q que que def main():
    List = deque()
    n = int(input())
    for i in range(n):
        order = input().split()
        if order[0] == "insert":
            List.appendleft(order[1])
        elif order[0] == "delete":
            try:
                List.remove(order[1])
            except ValueError:
                pass
        elif order[0] == "deleteFirst":
            List.popleft()
        elif order[0] == "deleteLast":
            List.pop()
    print_list(List) main List = deque() List deque() deque n = int(input()) n int(input()) int input() input for i in range(n):
        order = input().split()
        if order[0] == "insert":
            List.appendleft(order[1])
        elif order[0] == "delete":
            try:
                List.remove(order[1])
            except ValueError:
                pass
        elif order[0] == "deleteFirst":
            List.popleft()
        elif order[0] == "deleteLast":
            List.pop()
     i range(n) range n order = input().split() order input().split() ().split () input split if order[0] == "insert":
            List.appendleft(order[1])
        elif order[0] == "delete":
            try:
                List.remove(order[1])
            except ValueError:
                pass
        elif order[0] == "deleteFirst":
            List.popleft()
        elif order[0] == "deleteLast":
            List.pop()
     order[0] == "insert" order[0] order 0 "insert" List.appendleft(order[1]) List.appendleft List appendleft order[1] order 1 elif order[0] == "delete":
            try:
                List.remove(order[1])
            except ValueError:
                pass
         order[0] == "delete" order[0] order 0 "delete" try:
                List.remove(order[1])
            except ValueError:
                pass
         except ValueError:
                pass
         List.remove(order[1]) List.remove List remove order[1] order 1 elif order[0] == "deleteFirst":
            List.popleft()
         order[0] == "deleteFirst" order[0] order 0 "deleteFirst" List.popleft() List.popleft List popleft elif order[0] == "deleteLast":
            List.pop()
     order[0] == "deleteLast" order[0] order 0 "deleteLast" List.pop() List.pop List pop print_list(List) print_list List if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    List = deque()
    n = int(input())
    for i in range(n):
        order = input().split()
        if order[0] == "insert":
            List.appendleft(order[1])
        elif order[0] == "delete":
            try:
                List.remove(order[1])
            except ValueError:
                pass
        elif order[0] == "deleteFirst":
            List.popleft()
        elif order[0] == "deleteLast":
            List.pop()
    print_list(List) def main():
    List = deque()
    n = int(input())
    for i in range(n):
        order = input().split()
        if order[0] == "insert":
            List.appendleft(order[1])
        elif order[0] == "delete":
            try:
                List.remove(order[1])
            except ValueError:
                pass
        elif order[0] == "deleteFirst":
            List.popleft()
        elif order[0] == "deleteLast":
            List.pop()
    print_list(List) main def print_list(que):
    for i, q in enumerate(que):
        if i != len(que)-1:
            print(q, end=' ')
        else:
            print(q) def print_list(que):
    for i, q in enumerate(que):
        if i != len(que)-1:
            print(q, end=' ')
        else:
            print(q) print_list
from collections import deque


def print_list(que):
    for i, q in enumerate(que):
        if i != len(que)-1:
            print(q, end=' ')
        else:
            print(q)


def main():
    List = deque()
    n = int(input())
    for i in range(n):
        order = input().split()
        if order[0] == "insert":
            List.appendleft(order[1])
        elif order[0] == "delete":
            try:
                List.remove(order[1])
            except ValueError:
                pass
        elif order[0] == "deleteFirst":
            List.popleft()
        elif order[0] == "deleteLast":
            List.pop()
    print_list(List)


if __name__ == "__main__":
    main()

