Let $D$ be an integral domain and $a,~b \in D$. Suppose that $a^n=b^n$ and $a^m=b^m$ for any two some $m,~n$ such that $(m,n)=1$. Prove that $a=b$.
I know that $ab≠0$ since $D$ contains no divisors of zero, but I don’t have an idea as to how to prove this.