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

from collections import deque
import sys

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

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    ans = deque()
    inp = sys.stdin.readlines()
    for i in range(n):
        com = inp[i].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 import sys sys COMMAND = ("insert", "delete", "deleteFirst", "deleteLast") COMMAND ("insert", "delete", "deleteFirst", "deleteLast") "insert" "delete" "deleteFirst" "deleteLast" if __name__ == "__main__":
    n = int(sys.stdin.readline())
    ans = deque()
    inp = sys.stdin.readlines()
    for i in range(n):
        com = inp[i].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(sys.stdin.readline()) n int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline ans = deque() ans deque() deque inp = sys.stdin.readlines() inp sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines for i in range(n):
        com = inp[i].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 = inp[i].split() com inp[i].split() [i].split [i] inp i 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 COMMAND = ("insert", "delete", "deleteFirst", "deleteLast") ("insert", "delete", "deleteFirst", "deleteLast") COMMAND com = inp[i].split() inp[i].split() com n = int(sys.stdin.readline()) int(sys.stdin.readline()) n inp = sys.stdin.readlines() sys.stdin.readlines() inp ans = deque() deque() ans
# -*- coding: utf-8 -*-

from collections import deque
import sys

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

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    ans = deque()
    inp = sys.stdin.readlines()
    for i in range(n):
        com = inp[i].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))