Let $G_1$ and $G_2$ be finite groups and let $K \le G_1 \times G_2$
(i) Set $H_1 = \{ g \in G_1 : (g,e) \in K \}$ and $H_2 = \{ g \in G_2 : (e,g) \in K \}$. Show that: $$H_1 \le G_1; \quad H_2 \le G_2; \quad H_1 \times H_2 \le K.$$
(ii) Suppose that $|G_1|$ and $|G_2|$ are coprime. Show that $K = H_1 \times H_2$.
(iii) Show that this result need not follow if $|G_1|$ and $|G_2|$ are not coprime.
I have done part (i). I was doing part (ii) and got stuck:
Since from above I showed that $H_1 \times H_2 \subseteq K$, now I only need to show that $H_1 \times H_2 \supseteq K$.
Let $(g_1,g_2) \in K$ where $g_1 \in G_1$ and $g_2 \in G_2$. Since $K \leq G_1 \times G_2$, we have $(g_1,e) \in K$ and $(e,g_2) \in K$. Hence $g_1 \in H_1$ and $g_2 \in H_2$.
Finally we have $(g_1, g_2) \in H_1 \times H_2$
As I haven't used the fact that order of $G_1$ and $G_2$ are coprime, there must be something fundamentally wrong with my proof.
Let $a = |G_1|$ be the order of $G_1$ and $b = |G_2|$ be the order of $G_2$. By Bézout's theorem, there are integers $u,v$ such that $au + bv = 1$. Let $(g_1, g_2) \in K$; we want to show that $g_1 \in H_1$ and $g_2 \in H_2$. But we have: $g_1^a = e \implies g_1^{au} = e = g_1^{1-bv} \implies g_1^{bv} = g_1$, and similarly $g_2^{au} = g_2$.
Thus $(g_1,e) = (g_1^{bv}, g_2^{bv}) = (g_1, g_2)^{bv}$ belongs to $K$ (because $(g_1,g_2)$ does), and so by definition $g_1 \in H_1$. Similarly using $g_2^{au} = g_2$, you get $g_2 \in H_2$.