This exercise is taken from Munkres' Algebraic Topology book, it is in Section 6 of Chapter 1.
The problem asks you to find a $2$-dimensional complex $K$ with underlying space $|K|$ connected and $H_1(K)\simeq G_1$, $H_2(K)\simeq G_2$. Where $G_1$ and $G_2$ are finitely generated abelian groups and $G_2$ is free.
I see how one can have any finitely generated abelian group as the first homology, it is enough to take the wedge sum of $k$-fold "dunce caps" for the torsion part and adding loops to get the desired rank.
However I don't see how I can have $H_2(K)\simeq G_2$ and $H_1(K)\simeq G_1$ for general $G_1$ and $G_2$ simultaneously. The best idea I had so far was to include the wedge sum of spaces of the type
Where we identify the corners of the square and the edges in the indicated directions. If I'm not wrong this space has first homology $\mathbb{Z}$ and second homology $\mathbb{Z}$. So if the rank of $G_1$ is greater or equal than the rank of $G_2$ we are done. But this doesn't solve cases like $G_1=\mathbb{Z}/3\mathbb{Z}$ and $G_2=\mathbb{Z}$. How can one construct a space with those homology groups?
