Duality in quantum Toda theory and W-algebras