from collections import deque

def main():
    dq = deque()
    n = int(input())
    for _ in range(n):
        com = input().split()
        if com[0]=='insert':dq.appendleft(com[1])
        elif com[0]=='delete':
            try:dq.remove(com[1])
            except:pass
        elif com[0]=='deleteFirst':dq.popleft()
        else:dq.pop()
    print(' '.join(dq))



if __name__ == '__main__':
    main()

 from collections import deque def main():
    dq = deque()
    n = int(input())
    for _ in range(n):
        com = input().split()
        if com[0]=='insert':dq.appendleft(com[1])
        elif com[0]=='delete':
            try:dq.remove(com[1])
            except:pass
        elif com[0]=='deleteFirst':dq.popleft()
        else:dq.pop()
    print(' '.join(dq)) main dq = deque() dq deque() deque n = int(input()) n int(input()) int input() input for _ in range(n):
        com = input().split()
        if com[0]=='insert':dq.appendleft(com[1])
        elif com[0]=='delete':
            try:dq.remove(com[1])
            except:pass
        elif com[0]=='deleteFirst':dq.popleft()
        else:dq.pop()
     _ range(n) range n com = input().split() com input().split() ().split () input split if com[0]=='insert':dq.appendleft(com[1])
        elif com[0]=='delete':
            try:dq.remove(com[1])
            except:pass
        elif com[0]=='deleteFirst':dq.popleft()
        else:dq.pop()
     com[0]=='insert' com[0] com 0 'insert' elif com[0]=='delete':
            try:dq.remove(com[1])
            except:pass
         com[0]=='delete' com[0] com 0 'delete' try:dq.remove(com[1])
            except:pass
         except:pass
         elif com[0]=='deleteFirst':dq.popleft()
         com[0]=='deleteFirst' com[0] com 0 'deleteFirst' print(' '.join(dq)) print ' '.join(dq) ' '.join ' ' join dq if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    dq = deque()
    n = int(input())
    for _ in range(n):
        com = input().split()
        if com[0]=='insert':dq.appendleft(com[1])
        elif com[0]=='delete':
            try:dq.remove(com[1])
            except:pass
        elif com[0]=='deleteFirst':dq.popleft()
        else:dq.pop()
    print(' '.join(dq)) def main():
    dq = deque()
    n = int(input())
    for _ in range(n):
        com = input().split()
        if com[0]=='insert':dq.appendleft(com[1])
        elif com[0]=='delete':
            try:dq.remove(com[1])
            except:pass
        elif com[0]=='deleteFirst':dq.popleft()
        else:dq.pop()
    print(' '.join(dq)) main
from collections import deque

def main():
    dq = deque()
    n = int(input())
    for _ in range(n):
        com = input().split()
        if com[0]=='insert':dq.appendleft(com[1])
        elif com[0]=='delete':
            try:dq.remove(com[1])
            except:pass
        elif com[0]=='deleteFirst':dq.popleft()
        else:dq.pop()
    print(' '.join(dq))



if __name__ == '__main__':
    main()


