from collections import deque
a = int(input())

dl = deque()
for i in range(a):
    o = input().split()

    if o[0] == 'delete':
        try:
            dl.remove(o[1])
        except ValueError:
            pass
    elif o[0] == 'deleteFirst':
        dl.popleft()
    elif o[0] == 'deleteLast':
        dl.pop()
    else:
        dl.appendleft(o[1])

print(" ".join([str(i) for i in dl]))
 from collections import deque a = int(input()) a int(input()) int input() input dl = deque() dl deque() deque for i in range(a):
    o = input().split()

    if o[0] == 'delete':
        try:
            dl.remove(o[1])
        except ValueError:
            pass
    elif o[0] == 'deleteFirst':
        dl.popleft()
    elif o[0] == 'deleteLast':
        dl.pop()
    else:
        dl.appendleft(o[1]) i range(a) range a o = input().split() o input().split() ().split () input split if o[0] == 'delete':
        try:
            dl.remove(o[1])
        except ValueError:
            pass
    elif o[0] == 'deleteFirst':
        dl.popleft()
    elif o[0] == 'deleteLast':
        dl.pop()
    else:
        dl.appendleft(o[1]) o[0] == 'delete' o[0] o 0 'delete' try:
            dl.remove(o[1])
        except ValueError:
            pass
     except ValueError:
            pass
     dl.remove(o[1]) dl.remove dl remove o[1] o 1 elif o[0] == 'deleteFirst':
        dl.popleft()
     o[0] == 'deleteFirst' o[0] o 0 'deleteFirst' dl.popleft() dl.popleft dl popleft elif o[0] == 'deleteLast':
        dl.pop()
     o[0] == 'deleteLast' o[0] o 0 'deleteLast' dl.pop() dl.pop dl pop dl.appendleft(o[1]) dl.appendleft dl appendleft o[1] o 1 str(i) for i in dl for i in dl i dl for i in dl str(i) str i print(" ".join([str(i) for i in dl])) print " ".join([str(i) for i in dl]) " ".join " " join [str(i) for i in dl] a = int(input()) int(input()) a o = input().split() input().split() o dl = deque() deque() dl
from collections import deque
a = int(input())

dl = deque()
for i in range(a):
    o = input().split()

    if o[0] == 'delete':
        try:
            dl.remove(o[1])
        except ValueError:
            pass
    elif o[0] == 'deleteFirst':
        dl.popleft()
    elif o[0] == 'deleteLast':
        dl.pop()
    else:
        dl.appendleft(o[1])

print(" ".join([str(i) for i in dl]))

