If A and B were open subsets of X, we could apply Lemma 1 with U=A and V=B to determine the structure of .
Alternatively, we need to choose two open sets U and V such that A and B are deformation retracts of U and V, respectively.
Choose the circles and lines and such that if you remove the from A and from B, A and B should become simply connected (Think of a reverse procedure of making a torus from a rectangle paper).
Let and , where does not belong to any and . Then, A and B are deformation retracts of U and V, respectively
Now, we have , and , where is contractible.
Then, by lemma 1, we conclude that is the free product of groups and , or the free product of groups and .
Since and , is isomorphic to the free product of groups and .