from collections import deque

n = int(input())
cmdlst = [input() for cmd in range(n)]
lst = deque()

for cmd in cmdlst:
    if cmd == 'deleteFirst':
        lst.popleft()
    elif cmd == 'deleteLast':
        lst.pop()
    else:
        cmd,x = cmd.split()
        if cmd == 'insert':
            lst.appendleft(x)
        else:
            try:
                lst.remove(x)
            except:
                pass
print(*lst) from collections import deque n = int(input()) n int(input()) int input() input input() for cmd in range(n) for cmd in range(n) cmd range(n) range n for cmd in range(n) input() input cmdlst = [input() for cmd in range(n)] cmdlst [input() for cmd in range(n)] lst = deque() lst deque() deque for cmd in cmdlst:
    if cmd == 'deleteFirst':
        lst.popleft()
    elif cmd == 'deleteLast':
        lst.pop()
    else:
        cmd,x = cmd.split()
        if cmd == 'insert':
            lst.appendleft(x)
        else:
            try:
                lst.remove(x)
            except:
                pass cmd cmdlst if cmd == 'deleteFirst':
        lst.popleft()
    elif cmd == 'deleteLast':
        lst.pop()
    else:
        cmd,x = cmd.split()
        if cmd == 'insert':
            lst.appendleft(x)
        else:
            try:
                lst.remove(x)
            except:
                pass cmd == 'deleteFirst' cmd 'deleteFirst' lst.popleft() lst.popleft lst popleft elif cmd == 'deleteLast':
        lst.pop()
     cmd == 'deleteLast' cmd 'deleteLast' lst.pop() lst.pop lst pop cmd,x = cmd.split() cmd cmd.split() cmd.split cmd split x if cmd == 'insert':
            lst.appendleft(x)
        else:
            try:
                lst.remove(x)
            except:
                pass cmd == 'insert' cmd 'insert' lst.appendleft(x) lst.appendleft lst appendleft x try:
                lst.remove(x)
            except:
                pass except:
                pass lst.remove(x) lst.remove lst remove x print(*lst) print *lst lst n = int(input()) int(input()) n x = cmd.split() cmd.split() x cmdlst = [input() for cmd in range(n)] [input() for cmd in range(n)] cmdlst lst = deque() deque() lst cmd,x = cmd.split() cmd.split() cmd
from collections import deque

n = int(input())
cmdlst = [input() for cmd in range(n)]
lst = deque()

for cmd in cmdlst:
    if cmd == 'deleteFirst':
        lst.popleft()
    elif cmd == 'deleteLast':
        lst.pop()
    else:
        cmd,x = cmd.split()
        if cmd == 'insert':
            lst.appendleft(x)
        else:
            try:
                lst.remove(x)
            except:
                pass
print(*lst)
