import sys
import array
from collections import deque


def main():
    n = int(input())
    #l = array.array('L')
    l = deque()
    for _ in range(n):
        c = sys.stdin.readline().split()
        if c[0] == "insert":
            l.appendleft(int(c[1]))
        elif c[0] == "delete":
            if int(c[1]) in l:
                l.remove(int(c[1]))
        elif c[0] == "deleteFirst":
            l.popleft()
        elif c[0] == "deleteLast":
            l.pop()
    print(*l)


if __name__ == "__main__":
    main() import sys sys import array array from collections import deque def main():
    n = int(input())
    #l = array.array('L')
    l = deque()
    for _ in range(n):
        c = sys.stdin.readline().split()
        if c[0] == "insert":
            l.appendleft(int(c[1]))
        elif c[0] == "delete":
            if int(c[1]) in l:
                l.remove(int(c[1]))
        elif c[0] == "deleteFirst":
            l.popleft()
        elif c[0] == "deleteLast":
            l.pop()
    print(*l) main n = int(input()) n int(input()) int input() input l = deque() l deque() deque for _ in range(n):
        c = sys.stdin.readline().split()
        if c[0] == "insert":
            l.appendleft(int(c[1]))
        elif c[0] == "delete":
            if int(c[1]) in l:
                l.remove(int(c[1]))
        elif c[0] == "deleteFirst":
            l.popleft()
        elif c[0] == "deleteLast":
            l.pop()
     _ range(n) range n c = sys.stdin.readline().split() c sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split if c[0] == "insert":
            l.appendleft(int(c[1]))
        elif c[0] == "delete":
            if int(c[1]) in l:
                l.remove(int(c[1]))
        elif c[0] == "deleteFirst":
            l.popleft()
        elif c[0] == "deleteLast":
            l.pop()
     c[0] == "insert" c[0] c 0 "insert" l.appendleft(int(c[1])) l.appendleft l appendleft int(c[1]) int c[1] c 1 elif c[0] == "delete":
            if int(c[1]) in l:
                l.remove(int(c[1]))
         c[0] == "delete" c[0] c 0 "delete" if int(c[1]) in l:
                l.remove(int(c[1]))
         int(c[1]) in l int(c[1]) int c[1] c 1 l l.remove(int(c[1])) l.remove l remove int(c[1]) int c[1] c 1 elif c[0] == "deleteFirst":
            l.popleft()
         c[0] == "deleteFirst" c[0] c 0 "deleteFirst" l.popleft() l.popleft l popleft elif c[0] == "deleteLast":
            l.pop()
     c[0] == "deleteLast" c[0] c 0 "deleteLast" l.pop() l.pop l pop print(*l) print *l l if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n = int(input())
    #l = array.array('L')
    l = deque()
    for _ in range(n):
        c = sys.stdin.readline().split()
        if c[0] == "insert":
            l.appendleft(int(c[1]))
        elif c[0] == "delete":
            if int(c[1]) in l:
                l.remove(int(c[1]))
        elif c[0] == "deleteFirst":
            l.popleft()
        elif c[0] == "deleteLast":
            l.pop()
    print(*l) def main():
    n = int(input())
    #l = array.array('L')
    l = deque()
    for _ in range(n):
        c = sys.stdin.readline().split()
        if c[0] == "insert":
            l.appendleft(int(c[1]))
        elif c[0] == "delete":
            if int(c[1]) in l:
                l.remove(int(c[1]))
        elif c[0] == "deleteFirst":
            l.popleft()
        elif c[0] == "deleteLast":
            l.pop()
    print(*l) main
import sys
import array
from collections import deque


def main():
    n = int(input())
    #l = array.array('L')
    l = deque()
    for _ in range(n):
        c = sys.stdin.readline().split()
        if c[0] == "insert":
            l.appendleft(int(c[1]))
        elif c[0] == "delete":
            if int(c[1]) in l:
                l.remove(int(c[1]))
        elif c[0] == "deleteFirst":
            l.popleft()
        elif c[0] == "deleteLast":
            l.pop()
    print(*l)


if __name__ == "__main__":
    main()
