If $f:M\to N$, $g:N\to P$ continuous and $g\circ f: M\to P$ is a homeomorphism. And $g$ is injective (or $f$ is surjective) then $g, f$ both are homeomorphisms.
I don't know how to prove it. I tried to use the left inverse of $g$ (or right inverse of $f$), but I can't follow it up.