from collections import deque

def main():
    lst = deque()

    n = int(input())

    for _ in range(n):
        cmd = input().split()

        if 'insert' == cmd[0]:
            lst.appendleft(cmd[1])
        if 'delete' == cmd[0]:
            try:
                lst.remove(cmd[1])
            except:
                pass
        if 'deleteFirst' == cmd[0]:
            lst.popleft()
        if 'deleteLast' == cmd[0]:
            lst.pop()

    sep = ''
    for n in lst:
        print(sep+n, end='')
        sep = ' '
    print()

if __name__ == '__main__':
    main()
 from collections import deque def main():
    lst = deque()

    n = int(input())

    for _ in range(n):
        cmd = input().split()

        if 'insert' == cmd[0]:
            lst.appendleft(cmd[1])
        if 'delete' == cmd[0]:
            try:
                lst.remove(cmd[1])
            except:
                pass
        if 'deleteFirst' == cmd[0]:
            lst.popleft()
        if 'deleteLast' == cmd[0]:
            lst.pop()

    sep = ''
    for n in lst:
        print(sep+n, end='')
        sep = ' '
    print() main lst = deque() lst deque() deque n = int(input()) n int(input()) int input() input for _ in range(n):
        cmd = input().split()

        if 'insert' == cmd[0]:
            lst.appendleft(cmd[1])
        if 'delete' == cmd[0]:
            try:
                lst.remove(cmd[1])
            except:
                pass
        if 'deleteFirst' == cmd[0]:
            lst.popleft()
        if 'deleteLast' == cmd[0]:
            lst.pop()

     _ range(n) range n cmd = input().split() cmd input().split() ().split () input split if 'insert' == cmd[0]:
            lst.appendleft(cmd[1])
         'insert' == cmd[0] 'insert' cmd[0] cmd 0 lst.appendleft(cmd[1]) lst.appendleft lst appendleft cmd[1] cmd 1 if 'delete' == cmd[0]:
            try:
                lst.remove(cmd[1])
            except:
                pass
         'delete' == cmd[0] 'delete' cmd[0] cmd 0 try:
                lst.remove(cmd[1])
            except:
                pass
         except:
                pass
         lst.remove(cmd[1]) lst.remove lst remove cmd[1] cmd 1 if 'deleteFirst' == cmd[0]:
            lst.popleft()
         'deleteFirst' == cmd[0] 'deleteFirst' cmd[0] cmd 0 lst.popleft() lst.popleft lst popleft if 'deleteLast' == cmd[0]:
            lst.pop()

     'deleteLast' == cmd[0] 'deleteLast' cmd[0] cmd 0 lst.pop() lst.pop lst pop sep = '' sep '' for n in lst:
        print(sep+n, end='')
        sep = ' '
     n lst print(sep+n, end='') print sep+n sep n end='' end '' sep = ' ' sep ' ' print() print if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    lst = deque()

    n = int(input())

    for _ in range(n):
        cmd = input().split()

        if 'insert' == cmd[0]:
            lst.appendleft(cmd[1])
        if 'delete' == cmd[0]:
            try:
                lst.remove(cmd[1])
            except:
                pass
        if 'deleteFirst' == cmd[0]:
            lst.popleft()
        if 'deleteLast' == cmd[0]:
            lst.pop()

    sep = ''
    for n in lst:
        print(sep+n, end='')
        sep = ' '
    print() def main():
    lst = deque()

    n = int(input())

    for _ in range(n):
        cmd = input().split()

        if 'insert' == cmd[0]:
            lst.appendleft(cmd[1])
        if 'delete' == cmd[0]:
            try:
                lst.remove(cmd[1])
            except:
                pass
        if 'deleteFirst' == cmd[0]:
            lst.popleft()
        if 'deleteLast' == cmd[0]:
            lst.pop()

    sep = ''
    for n in lst:
        print(sep+n, end='')
        sep = ' '
    print() main
from collections import deque

def main():
    lst = deque()

    n = int(input())

    for _ in range(n):
        cmd = input().split()

        if 'insert' == cmd[0]:
            lst.appendleft(cmd[1])
        if 'delete' == cmd[0]:
            try:
                lst.remove(cmd[1])
            except:
                pass
        if 'deleteFirst' == cmd[0]:
            lst.popleft()
        if 'deleteLast' == cmd[0]:
            lst.pop()

    sep = ''
    for n in lst:
        print(sep+n, end='')
        sep = ' '
    print()

if __name__ == '__main__':
    main()

