Quasiseparation of variables in the Schrödinger equation with a magnetic field