#-*-coding:utf-8-*-

from collections import deque
import sys
input=sys.stdin.readline

def main():
    commands=[]
    number = int(input())
    commands=list(input().split() for _ in range(number))
    q=deque()
    for command in commands:
        if command[0] == "insert":
            q.appendleft(command[1])
        elif command[0] == "delete":
            if command[1] in q:
                q.remove(command[1])
            else:
                continue
        elif command[0] == "deleteFirst":
            q.popleft()
        elif command[0] == "deleteLast":
            q.pop()
    print(*q)
if __name__=="__main__":
    main() from collections import deque import sys sys input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    commands=[]
    number = int(input())
    commands=list(input().split() for _ in range(number))
    q=deque()
    for command in commands:
        if command[0] == "insert":
            q.appendleft(command[1])
        elif command[0] == "delete":
            if command[1] in q:
                q.remove(command[1])
            else:
                continue
        elif command[0] == "deleteFirst":
            q.popleft()
        elif command[0] == "deleteLast":
            q.pop()
    print(*q) main commands=[] commands [] number = int(input()) number int(input()) int input() input commands=list(input().split() for _ in range(number)) commands list(input().split() for _ in range(number)) list input().split() ().split () input split q=deque() q deque() deque for command in commands:
        if command[0] == "insert":
            q.appendleft(command[1])
        elif command[0] == "delete":
            if command[1] in q:
                q.remove(command[1])
            else:
                continue
        elif command[0] == "deleteFirst":
            q.popleft()
        elif command[0] == "deleteLast":
            q.pop()
     command commands if command[0] == "insert":
            q.appendleft(command[1])
        elif command[0] == "delete":
            if command[1] in q:
                q.remove(command[1])
            else:
                continue
        elif command[0] == "deleteFirst":
            q.popleft()
        elif command[0] == "deleteLast":
            q.pop()
     command[0] == "insert" command[0] command 0 "insert" q.appendleft(command[1]) q.appendleft q appendleft command[1] command 1 elif command[0] == "delete":
            if command[1] in q:
                q.remove(command[1])
            else:
                continue
         command[0] == "delete" command[0] command 0 "delete" if command[1] in q:
                q.remove(command[1])
            else:
                continue
         command[1] in q command[1] command 1 q q.remove(command[1]) q.remove q remove command[1] command 1 continue elif command[0] == "deleteFirst":
            q.popleft()
         command[0] == "deleteFirst" command[0] command 0 "deleteFirst" q.popleft() q.popleft q popleft elif command[0] == "deleteLast":
            q.pop()
     command[0] == "deleteLast" command[0] command 0 "deleteLast" q.pop() q.pop q pop print(*q) print *q q if __name__=="__main__":
    main() __name__=="__main__" __name__ "__main__" main() main def main():
    commands=[]
    number = int(input())
    commands=list(input().split() for _ in range(number))
    q=deque()
    for command in commands:
        if command[0] == "insert":
            q.appendleft(command[1])
        elif command[0] == "delete":
            if command[1] in q:
                q.remove(command[1])
            else:
                continue
        elif command[0] == "deleteFirst":
            q.popleft()
        elif command[0] == "deleteLast":
            q.pop()
    print(*q) def main():
    commands=[]
    number = int(input())
    commands=list(input().split() for _ in range(number))
    q=deque()
    for command in commands:
        if command[0] == "insert":
            q.appendleft(command[1])
        elif command[0] == "delete":
            if command[1] in q:
                q.remove(command[1])
            else:
                continue
        elif command[0] == "deleteFirst":
            q.popleft()
        elif command[0] == "deleteLast":
            q.pop()
    print(*q) main input=sys.stdin.readline sys.stdin.readline input
#-*-coding:utf-8-*-

from collections import deque
import sys
input=sys.stdin.readline

def main():
    commands=[]
    number = int(input())
    commands=list(input().split() for _ in range(number))
    q=deque()
    for command in commands:
        if command[0] == "insert":
            q.appendleft(command[1])
        elif command[0] == "delete":
            if command[1] in q:
                q.remove(command[1])
            else:
                continue
        elif command[0] == "deleteFirst":
            q.popleft()
        elif command[0] == "deleteLast":
            q.pop()
    print(*q)
if __name__=="__main__":
    main()
