Abelian Group Element Orders
Saying that $m/g$ and $n$ are coprime is wrong. Consider $n=12$, $m=18$, the standard example. What is true is that $m/g$ and $n/g$ are coprime. But if you want to complete the proof using the elements $a^g,b^g$, then you will realise that although these now have coprime orders, the least common multiple (=product) of those orders is no longer $\def\lcm{\operatorname{lcm}}\lcm(n,m)$, but $\lcm(n,m)/g$.
So instead another idea is needed. The best I have been able to think of is treat all prime numbers $p$ dividing $nm$ separately; if $p$ divides the order of only one of $a,b$ then there is nothing to do for $p$, but if it divides both orders, then keep the element in which the multiplicity is highest (choose one in case of a tie) and kill the factors $p$ in the order of the other element (say it was $b$) by replacing $b$ by $b^{p^i}$ (where $i$ is the minority multiplicity). This modification is designed to leave the least common multiple of the orders of $a,b$ intact, and when all primes have been processed the greatest common divisor has become$~1$. After these modifications, the element $ab$ has the desired order.