So for this case, I have confusion in case m in $Z_m$ is odd. Suppose that f is a homomorphism.
Then $f(12)=0$ (if not then Lagrange's theorem is violated).
f(123) should either map to 0 or an element of order 3 in $Z_m$. So if m is not divisible by 3 then $f(123)=0$ and we get a trivial mapping.