Ultraluminous infrared galaxies and the origin of quasars