def resolve():
    from collections import deque
    n = int(input())
    que = deque()
    for _ in range(n):
        cv = input().split()
        if cv[0] == "insert":
            x = int(cv[1])
            que.appendleft(x)
        elif cv[0] == "delete":
            x = int(cv[1])
            if x in que:
                que.remove(x)
        elif cv[0] == "deleteFirst":
            que.popleft()
        elif cv[0] == "deleteLast":
            que.pop()
    ans = list(que)
    print(*ans)


resolve()
 def resolve():
    from collections import deque
    n = int(input())
    que = deque()
    for _ in range(n):
        cv = input().split()
        if cv[0] == "insert":
            x = int(cv[1])
            que.appendleft(x)
        elif cv[0] == "delete":
            x = int(cv[1])
            if x in que:
                que.remove(x)
        elif cv[0] == "deleteFirst":
            que.popleft()
        elif cv[0] == "deleteLast":
            que.pop()
    ans = list(que)
    print(*ans) resolve from collections import deque n = int(input()) n int(input()) int input() input que = deque() que deque() deque for _ in range(n):
        cv = input().split()
        if cv[0] == "insert":
            x = int(cv[1])
            que.appendleft(x)
        elif cv[0] == "delete":
            x = int(cv[1])
            if x in que:
                que.remove(x)
        elif cv[0] == "deleteFirst":
            que.popleft()
        elif cv[0] == "deleteLast":
            que.pop()
     _ range(n) range n cv = input().split() cv input().split() ().split () input split if cv[0] == "insert":
            x = int(cv[1])
            que.appendleft(x)
        elif cv[0] == "delete":
            x = int(cv[1])
            if x in que:
                que.remove(x)
        elif cv[0] == "deleteFirst":
            que.popleft()
        elif cv[0] == "deleteLast":
            que.pop()
     cv[0] == "insert" cv[0] cv 0 "insert" x = int(cv[1]) x int(cv[1]) int cv[1] cv 1 que.appendleft(x) que.appendleft que appendleft x elif cv[0] == "delete":
            x = int(cv[1])
            if x in que:
                que.remove(x)
         cv[0] == "delete" cv[0] cv 0 "delete" x = int(cv[1]) x int(cv[1]) int cv[1] cv 1 if x in que:
                que.remove(x)
         x in que x que que.remove(x) que.remove que remove x elif cv[0] == "deleteFirst":
            que.popleft()
         cv[0] == "deleteFirst" cv[0] cv 0 "deleteFirst" que.popleft() que.popleft que popleft elif cv[0] == "deleteLast":
            que.pop()
     cv[0] == "deleteLast" cv[0] cv 0 "deleteLast" que.pop() que.pop que pop ans = list(que) ans list(que) list que print(*ans) print *ans ans resolve() resolve def resolve():
    from collections import deque
    n = int(input())
    que = deque()
    for _ in range(n):
        cv = input().split()
        if cv[0] == "insert":
            x = int(cv[1])
            que.appendleft(x)
        elif cv[0] == "delete":
            x = int(cv[1])
            if x in que:
                que.remove(x)
        elif cv[0] == "deleteFirst":
            que.popleft()
        elif cv[0] == "deleteLast":
            que.pop()
    ans = list(que)
    print(*ans) def resolve():
    from collections import deque
    n = int(input())
    que = deque()
    for _ in range(n):
        cv = input().split()
        if cv[0] == "insert":
            x = int(cv[1])
            que.appendleft(x)
        elif cv[0] == "delete":
            x = int(cv[1])
            if x in que:
                que.remove(x)
        elif cv[0] == "deleteFirst":
            que.popleft()
        elif cv[0] == "deleteLast":
            que.pop()
    ans = list(que)
    print(*ans) resolve
def resolve():
    from collections import deque
    n = int(input())
    que = deque()
    for _ in range(n):
        cv = input().split()
        if cv[0] == "insert":
            x = int(cv[1])
            que.appendleft(x)
        elif cv[0] == "delete":
            x = int(cv[1])
            if x in que:
                que.remove(x)
        elif cv[0] == "deleteFirst":
            que.popleft()
        elif cv[0] == "deleteLast":
            que.pop()
    ans = list(que)
    print(*ans)


resolve()

