Fundamental group of $(A \sqcup B)/\{A \ni (z,0) \sim (z^p,z^q) \in B\}$ where $A = B = T^2$ and $p,q$ coprime Let $A,B$ be two copies of the torus $T^2:=\mathbb{S^1}\times\mathbb{S^1}$. Fix coprime integers $p, q \in \mathbb{Z}$. Compute the fundamental group of
$$C := A \sqcup B/ (A\ni (z, 0) \sim (z^p, z^q)\in B).$$
Clearly, we want to compute this using van Kampen. However, the glueing of the spaces confuses me.
As I have seen in another question, we could remove something simple from $C$ twice, which makes the fundamental group structure of both $U$ and $V$ easier to compute.
What would be a good choice of path-connected opens $U, V$ such that we can use their fundamental groups to compute the fundamental group of $C$?
 A: Let's take a moment to visualize the objects in question, at least in 2D.
We have a torus (with an embedded copy of $S^1$, shown squiggled):

which we're gluing to another torus along a more complicated copy of $S^1$ (also shown squiggled):

you can see that this copy of $S^1$ wraps around our square like a candy cane. In fact, before it meets itself, it wraps around the square $p$ many times "vertically",and $q$ many times "horizontally". See also here:

Let's call the first torus the "straight" torus, and the second torus the "candy cane" torus.

So what happens when we glue our toruses (tori?) together along the squiggly lines?
Well, we can do the standard Van Kampen trick: let $U$ be the straight torus, living as a subset of the final figure $C$. This isn't open, so we puff out just a little along the squiggly line into the candy cane torus. There's always an $\epsilon$ small enough to guarantee we keep a nice happy non-self-intersecting tube around the candy-cane squiggle, so this is an open set.
Similarly, we let $V$ be the candy cane torus (again, as a subset of $C$). This isn't open in the whole figure, so we puff out a little bit into the straight torus.
Now we find ourselves in the following situation:

*

*$U$ deformation retracts onto the straight torus

*$V$ deformation retracts onto the candy cane torus

*$U \cup V$ is the entire figure

*$U \cap V$ deformation retracts onto the squiggly $S^1$
We're now perfectly poised to use the Van Kampen theorem! This buys us a formula for the fundamental group of our whole figure:
$$\pi_1 C \cong \pi_1 U \  \underset{\pi_1 U \cap V}{\ast} \ \pi_1 V$$
Of course, we know the fundamental groups of torices and circles:
$$\pi_1 C \cong \mathbb Z^2 \underset{\mathbb{Z}}{\ast} \mathbb Z^2$$
This might be enough, but let's keep going! How might we fully compute this?

Well, we need to understand how $\mathbb{Z}$ sits inside of $\pi_1 U$ and inside $\pi_1 V$. That is, what loop does the squiggle represent?
For the straight torus, this is fairly easy: If our generators are $a$ and $b$ (say), then the squiggle corresponds to $a$.

For the candy cane torus, this takes a bit of thought. Call our generators $c$ and $d$. We want to find a homotopy from the squiggly line to some combination of these generating loops... A useful idea that shows up all the time in problems like this is to think outside the box:

From this image it becomes clear that the squiggly line is homotopic to $c^pd^q$. Just push it down towards the bottom right.
And now, when we amalgamate, we want to make the copy of $\mathbb{Z}$ generated by the straight squiggle equal to the copy of $\mathbb{Z}$ generated by the candy cane squiggle (since they're really the same squiggle!). How do we do that?

*

*$\pi_1 U = \langle a, b \mid [a,b] \rangle$

*$\pi_1 V = \langle c, d \mid [c,d] \rangle$

*$\pi_1 U \cap V = \langle s \rangle$ (for squiggle)

*$\pi_1 U \cap V \hookrightarrow \pi_1 U$ by $s \mapsto a$

*$\pi_1 U \cap V \hookrightarrow \pi_1 V$ by $s \mapsto c^pd^q$
This looks like a lot of information, but really we're just naming the things we already knew about so that we can write down the explicit inclusion maps for the fundamental group of the squiggle.
But now we see the light at the end of the tunnel: We amalgamate to see
$$
\begin{aligned}
\pi_1 C 
&= \pi_1 U \underset{\pi_1 U \cap V}{\ast} \pi_1 V \\
&= \langle a, b \mid [a,b] \rangle 
\underset{\langle s \rangle}{\ast} 
\langle c, d \mid [c,d] \rangle \\
&= \langle a, b, c, d \mid [a,b], [c,d], a = c^pd^q \rangle
\end{aligned}
$$
It's possible this can be simplified more, but I'll leave that to a better combinatorial group theorist than me.

I hope this helps ^_^
