If $f:M\to N$, $g:N\to P$ continuous and $g\circ f: M\to P$ are homeomorphism, and $g$ is injective, then $g, f$ both are homeomorphisms 
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.

Suppose that $g$ is injective. It’s also continuous, so it’s a homeomorphism iff it is open. To show that $g$ is open, let $U$ be any open subset of $N$. The map $f$ is continuous, so $f^{-1}[U]$ is open in $M$. The map $g\circ f$ is a homeomorphism, so $g[U]=(g\circ f)[f^{-1}[U]]$ is open in $P$, and therefore $g$ is open.
Note that since $g\circ f$ is injective, $f$ must be injective as well. Thus, to show that $f$ is a homeomorphism, you need only show that it is open. For this you can use the same sort of reasoning as I used above.
