The solution for someone who really prefers algebra to geometry:
Let $AZ=p$, $XC=q$. Then the Pythagorean theorem tells us that \begin{eqnarray} p^2+m^2&=&r^2\\ q^2+m^2&=&s^2\\ (p+m)^2+(q+m)^2&=&(r+s)^2 \, . \end{eqnarray} Subtracting the first two equations from the third and simplifying yields $p+q=\frac{rs}{m}$, while subtracting the second equation from the first yields $p^2-q^2=r^2-s^2$. So $p-q=\frac{m}{rs}(r^2-s^2)$, and thus $p=\frac{1}{2}\left(\frac{mr}{s}+\frac{rs}{m}-\frac{ms}{r}\right) \, .$ Substituting this value into the first Pythagorean relation, we have $\frac{1}{4}\left(\frac{m^2r^2}{s^2}+\frac{r^2s^2}{m^2}+\frac{m^2s^2}{r^2}+2r^2-2s^2-2m^2\right)+m^2-r^2=0 \\ \frac{1}{4}\left(\frac{m^2r^2}{s^2}+\frac{r^2s^2}{m^2}+\frac{m^2s^2}{r^2}-2r^2-2s^2+2m^2\right)=0 \\ \left(\frac{mr}{s}-\frac{rs}{m}+\frac{ms}{r}\right)^2=0 \, ;$ isolating $m$ gives $m^2=\frac{rs}{\frac{r}{s}+\frac{s}{r}} \, .$