from collections import deque

if __name__ == '__main__':
    l = deque()
    n = int(input())
    for _ in range(n):
        m = input().split()
        if m[0] == 'insert':
            l.appendleft(m[1])
        elif m[0] == 'delete':
            try:
                l.remove(m[1])
            except:
                pass
        elif m[0] == 'deleteFirst':
            l.popleft()
        elif m[0] == 'deleteLast':
            l.pop()
    print(' '.join(map(str, l)))
 from collections import deque if __name__ == '__main__':
    l = deque()
    n = int(input())
    for _ in range(n):
        m = input().split()
        if m[0] == 'insert':
            l.appendleft(m[1])
        elif m[0] == 'delete':
            try:
                l.remove(m[1])
            except:
                pass
        elif m[0] == 'deleteFirst':
            l.popleft()
        elif m[0] == 'deleteLast':
            l.pop()
    print(' '.join(map(str, l))) __name__ == '__main__' __name__ '__main__' l = deque() l deque() deque n = int(input()) n int(input()) int input() input for _ in range(n):
        m = input().split()
        if m[0] == 'insert':
            l.appendleft(m[1])
        elif m[0] == 'delete':
            try:
                l.remove(m[1])
            except:
                pass
        elif m[0] == 'deleteFirst':
            l.popleft()
        elif m[0] == 'deleteLast':
            l.pop()
     _ range(n) range n m = input().split() m input().split() ().split () input split if m[0] == 'insert':
            l.appendleft(m[1])
        elif m[0] == 'delete':
            try:
                l.remove(m[1])
            except:
                pass
        elif m[0] == 'deleteFirst':
            l.popleft()
        elif m[0] == 'deleteLast':
            l.pop()
     m[0] == 'insert' m[0] m 0 'insert' l.appendleft(m[1]) l.appendleft l appendleft m[1] m 1 elif m[0] == 'delete':
            try:
                l.remove(m[1])
            except:
                pass
         m[0] == 'delete' m[0] m 0 'delete' try:
                l.remove(m[1])
            except:
                pass
         except:
                pass
         l.remove(m[1]) l.remove l remove m[1] m 1 elif m[0] == 'deleteFirst':
            l.popleft()
         m[0] == 'deleteFirst' m[0] m 0 'deleteFirst' l.popleft() l.popleft l popleft elif m[0] == 'deleteLast':
            l.pop()
     m[0] == 'deleteLast' m[0] m 0 'deleteLast' l.pop() l.pop l pop print(' '.join(map(str, l))) print ' '.join(map(str, l)) ' '.join ' ' join map(str, l) map str l l = deque() deque() l n = int(input()) int(input()) n m = input().split() input().split() m
from collections import deque

if __name__ == '__main__':
    l = deque()
    n = int(input())
    for _ in range(n):
        m = input().split()
        if m[0] == 'insert':
            l.appendleft(m[1])
        elif m[0] == 'delete':
            try:
                l.remove(m[1])
            except:
                pass
        elif m[0] == 'deleteFirst':
            l.popleft()
        elif m[0] == 'deleteLast':
            l.pop()
    print(' '.join(map(str, l)))

