Let $i:\ker m\to P$ the the kernel of $m$ and $j:\ker n\to A$ that of $n$. Since $npi=qmi=0$ because $mi=0$, the universal property of $j$ implies there is a map $r:\ker m\to\ker n$ such that $jr=pi$.
Now consider the maps $j:\ker n\to A$ and $t=0:\ker n\to B$. Since $nj=0=qt$, there is a unique $s:ker n\to P$ such that $ps=j$ and $ms=t=0$. This last equation implies there is a $u:\ker n\to\ker m$ such that $iu=s$.
Can you see what the compositions $ru$ and $ur$ are?
For example: since $piur=psr=jr=pi$ and $miur=0ur=0=mi$, the universal property of the cartesian square implies that $iur=i$. Since $i$ is monic, it follows that $ur=\mathrm{id}_{\ker m}$. On the other hand, $jru=piu=ps=j$, and the monicness of $j$ implies now that $ru=\mathrm{id}_{\ker n}$.