Use the following facts to do your heavy lifting:
Proposition A. Given functions $g : Z \leftarrow Y$ and $f : Y \leftarrow X$...
If $g \circ f$ is surjective, then so too is $g$.
If $g \circ f$ is injective, then so too is $f$.
The proof is left as an exercise for the reader.
Proposition B. Given a function $f : Y \leftarrow X$ and a pair of isomorphisms $$\beta : Z \leftarrow Y \qquad \alpha : X \leftarrow W,$$ we have:
The following are equivalent:
$f$ is surjective, $\qquad$ $\beta \circ f$ is surjective, $\qquad$
$f \circ \alpha$ is surjective
The following are equivalent:
$f$ is injective, $\qquad$ $\beta \circ f$ is injective, $\qquad$ $f \circ \alpha$ is injective
Once again, the proof is left as an exercise for the reader.
Let us now turn our attention to your problem.
Claim. Given functions $q : A \leftarrow B$ and $p : B \leftarrow A$, if $q \circ p$ is surjective and $p \circ q$ is
injective, then $q$ and $p$ are isomorphisms.
Proof. From A1 and the surjectivity of $q \circ p$, we deduce that $q$ is surjective. From A2 and the injectivity of $p \circ q$, we deduce that $q$ is injective. Hence $q$ is an isomorphism.
From B1 and the surjectivity of $q \circ p$, we deduce that $p$ is surjective. From B2 and the injectivity of $q \circ p$, we deduce that $p$ is injective. Hence $q$ is an isomorphism. QED