__Case 1__: is simple, i.e. has no non-trivial normal subgroup. Suppose that has a non-trivial subgroup Since satisfies there exists a group homomorphism such that is the identity map. Then is a normal subgroup of and so either or If then and if then which are both false because is non-trivial. So has no non-trivial subgroup and hence it’s a cyclic group of prime order. That solves the problem in this case.

__Case 2__: is not simple. So has a non-trivial normal subgroup Since satisfies there exists a group homomorphism such that is the identity map. Let Note that since is non-trivial, is non-trivial too. Now, since is onto, and so Let Then and so Thus and hence Therefore, since are normal and we have The solution is now complete because, by the above claim, both satisfy and hence, by our induction hypothesis, both are a direct product of cyclic groups of prime orders and hence is also a direct product of cyclic groups of prime orders.