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

from collections import deque

COMMAND = ("insert", "delete", "deleteFirst", "deleteLast")

if __name__ == "__main__":
    n = int(input())
    ans = deque()
    for i in range(n):
        com = input().split()
        if com[0] == COMMAND[0]:
            ans.appendleft(com[1])
        elif com[0] == COMMAND[1]:
            if com[1] in ans:
                ans.remove(com[1])
        elif com[0] == COMMAND[2]:
            ans.popleft()
        elif com[0] == COMMAND[3]:
            ans.pop()
    print(" ".join(ans)) from collections import deque COMMAND = ("insert", "delete", "deleteFirst", "deleteLast") COMMAND ("insert", "delete", "deleteFirst", "deleteLast") "insert" "delete" "deleteFirst" "deleteLast" if __name__ == "__main__":
    n = int(input())
    ans = deque()
    for i in range(n):
        com = input().split()
        if com[0] == COMMAND[0]:
            ans.appendleft(com[1])
        elif com[0] == COMMAND[1]:
            if com[1] in ans:
                ans.remove(com[1])
        elif com[0] == COMMAND[2]:
            ans.popleft()
        elif com[0] == COMMAND[3]:
            ans.pop()
    print(" ".join(ans)) __name__ == "__main__" __name__ "__main__" n = int(input()) n int(input()) int input() input ans = deque() ans deque() deque for i in range(n):
        com = input().split()
        if com[0] == COMMAND[0]:
            ans.appendleft(com[1])
        elif com[0] == COMMAND[1]:
            if com[1] in ans:
                ans.remove(com[1])
        elif com[0] == COMMAND[2]:
            ans.popleft()
        elif com[0] == COMMAND[3]:
            ans.pop()
     i range(n) range n com = input().split() com input().split() ().split () input split if com[0] == COMMAND[0]:
            ans.appendleft(com[1])
        elif com[0] == COMMAND[1]:
            if com[1] in ans:
                ans.remove(com[1])
        elif com[0] == COMMAND[2]:
            ans.popleft()
        elif com[0] == COMMAND[3]:
            ans.pop()
     com[0] == COMMAND[0] com[0] com 0 COMMAND[0] COMMAND 0 ans.appendleft(com[1]) ans.appendleft ans appendleft com[1] com 1 elif com[0] == COMMAND[1]:
            if com[1] in ans:
                ans.remove(com[1])
         com[0] == COMMAND[1] com[0] com 0 COMMAND[1] COMMAND 1 if com[1] in ans:
                ans.remove(com[1])
         com[1] in ans com[1] com 1 ans ans.remove(com[1]) ans.remove ans remove com[1] com 1 elif com[0] == COMMAND[2]:
            ans.popleft()
         com[0] == COMMAND[2] com[0] com 0 COMMAND[2] COMMAND 2 ans.popleft() ans.popleft ans popleft elif com[0] == COMMAND[3]:
            ans.pop()
     com[0] == COMMAND[3] com[0] com 0 COMMAND[3] COMMAND 3 ans.pop() ans.pop ans pop print(" ".join(ans)) print " ".join(ans) " ".join " " join ans com = input().split() input().split() com n = int(input()) int(input()) n ans = deque() deque() ans COMMAND = ("insert", "delete", "deleteFirst", "deleteLast") ("insert", "delete", "deleteFirst", "deleteLast") COMMAND
# -*- coding: utf-8 -*-

from collections import deque

COMMAND = ("insert", "delete", "deleteFirst", "deleteLast")

if __name__ == "__main__":
    n = int(input())
    ans = deque()
    for i in range(n):
        com = input().split()
        if com[0] == COMMAND[0]:
            ans.appendleft(com[1])
        elif com[0] == COMMAND[1]:
            if com[1] in ans:
                ans.remove(com[1])
        elif com[0] == COMMAND[2]:
            ans.popleft()
        elif com[0] == COMMAND[3]:
            ans.pop()
    print(" ".join(ans))