Given natural numbers $m,n$ such that $m^2 + n^2 - m \equiv 0 \pmod{mn}$ and $p$ a prime dividing $m$, then I want to show that $p^2$ divides $m$.
I have tried multiple approaches: Euclidean division gives that $m = qp^2 + r$ for some $q, r \in \mathbb{N}$ where $0 \leq r < p^2$ and filling this in to show that $r = 0$. I also tried using that $p$ divides $m$ and $mn$ divides $m^2 + n^2 - m$ and again filling this in to find that $p^2$ has to divide $m$, but with no succes.
Any hints would be appreciated.
$\textbf{EDIT}$ Based on the given hint I have the following solution: Since $p$ divides $m$, we have that $p$ divides $mn$ and therefore $m^2 + n^2 - m$. Hence, there is some $k \in \mathbb{Z}$ such that $kp = m^2 + n^2 -m$ and therefore we have that $kp - m^2 + m = n^2$, so that $p$ divides $n^2$. Since $p$ is prime, it must divide $n$. Since $p$ divides both $m,n$ we have that $p^2$ divides $mn$ and therefore $m^2 + n^2 - m$. Also $p^2$ divides $m^2, n^2$ hence it must divide $m$.