Are the two groups isomorphic? Let $G,H,K$ be three groups. If $G\times H$ is isomorphic to $G\times K$, then is it true for $H\cong K$?
No, take

$$G=\mathbb{Z}\times\mathbb{Z}\times\cdots$$
$$H=\mathbb{Z}$$
$$K=1$$

Note that the thesis holds if $G$ is finite (Hirshon's theorem). See here.
Let $A=\prod\limits_{n=1}^{\infty}G_n$, where $G_n=\mathbb{Z}$ for all $n$.
And then we have $\mathbb{Z}\times A\cong\mathbb{Z}\times\mathbb{Z}\times A$. But $\mathbb{Z}\ncong\mathbb{Z}\times\mathbb{Z}$.