topological invariants hold for one space but not for the other, then two space cannot be homeomorphic. Fundamental groups and homology groups are also topological invariants, so two spaces that are homeomorphic have fundamental groups that are isomorphic.
The fundamental groups of the spaces in your question are
(Note that "*" is a free product, not a direct product " ". You can find the fundamental group of this space using Van-Kampen's theorem).
The spaces in your question cannot be homeomorphic to each other because their fundamental groups are not isomorphic to each other.