Prove that if $m, n, d\in\mathbb{Z^+}$ and $d \mid m^2n+1, d \mid mn^2+1$ then $d \mid m^3+1, d \mid n^3+1$
My attempt:
So I said that from this we can safely say that $$m^2n\equiv-1\pmod{d}, mn^2\equiv-1\pmod{d}$$ This means that: $$mn(m)\equiv mn(n)\pmod{d}$$ Now if $\gcd(mn, d)=1$ then we will get that $$m\equiv{n}\pmod{d}$$ Now in our original equation we will get $$m^2n+1\equiv0\pmod{d}, mn^2+1\equiv0\pmod{d}$$ $$\therefore m^3+1\equiv0\pmod{d}, n^3+1\equiv0\pmod{d}$$ But what if $\gcd(mn,d)\gt{1}$, what will I have to do? And is that even possible in the first place? Thank you in advance.