from collections import deque
n = int(input())
dl = deque()
for _ in range(n):
    cmd = input()
    if ' ' in cmd:
        op,v = cmd.split()
    else:
        op = cmd
    if   op == 'insert'     : dl.appendleft(v) 
    elif op == 'delete'     :
        try: dl.remove(v)
        except ValueError: pass
    elif op == 'deleteFirst': dl.popleft() 
    elif op == 'deleteLast' : dl.pop() 
print(*dl) from collections import deque n = int(input()) n int(input()) int input() input dl = deque() dl deque() deque for _ in range(n):
    cmd = input()
    if ' ' in cmd:
        op,v = cmd.split()
    else:
        op = cmd
    if   op == 'insert'     : dl.appendleft(v) 
    elif op == 'delete'     :
        try: dl.remove(v)
        except ValueError: pass
    elif op == 'deleteFirst': dl.popleft() 
    elif op == 'deleteLast' : dl.pop()  _ range(n) range n cmd = input() cmd input() input if ' ' in cmd:
        op,v = cmd.split()
    else:
        op = cmd
     ' ' in cmd ' ' cmd op,v = cmd.split() op cmd.split() cmd.split cmd split v op = cmd op cmd if   op == 'insert'     : dl.appendleft(v) 
    elif op == 'delete'     :
        try: dl.remove(v)
        except ValueError: pass
    elif op == 'deleteFirst': dl.popleft() 
    elif op == 'deleteLast' : dl.pop()  op == 'insert' op 'insert' elif op == 'delete'     :
        try: dl.remove(v)
        except ValueError: pass
     op == 'delete' op 'delete' try: dl.remove(v)
        except ValueError: pass
     except ValueError: pass
     elif op == 'deleteFirst': dl.popleft() 
     op == 'deleteFirst' op 'deleteFirst' elif op == 'deleteLast' : dl.po op == 'deleteLast' op 'deleteLast' print(*dl) print *dl dl dl = deque() deque() dl n = int(input()) int(input()) n v = cmd.split() cmd.split() v op,v = cmd.split() cmd.split() op cmd = input() input() cmd op = cmd cmd op
from collections import deque
n = int(input())
dl = deque()
for _ in range(n):
    cmd = input()
    if ' ' in cmd:
        op,v = cmd.split()
    else:
        op = cmd
    if   op == 'insert'     : dl.appendleft(v) 
    elif op == 'delete'     :
        try: dl.remove(v)
        except ValueError: pass
    elif op == 'deleteFirst': dl.popleft() 
    elif op == 'deleteLast' : dl.pop() 
print(*dl)