Fundamental group of two solid tori with boundaries identified via matrix action 
Let $D_i$ and $S^1_i$, for $i=1,2$, be two copies of the closed disk in $\mathbb R^2$ and its boundary. Let $M$ the integer matrix $$M:=\bigg(\matrix {a & b\\ c & d}\bigg),\ \det M\neq 0$$
  Identifying each $(\partial D_i)\times S^1_i$ with $\mathbb R^2/\mathbb Z^2$ we define $$\mu:(\partial D_1)\times S^1_1\to S^1_2\times(\partial D_2)$$ as the map induced by $M$ (note the order in the terms of the product).
Calculate the fundamental group $X_\mu:=(D_1\times S^1_1)\cup_\mu(S^1_2\times D_2)$ obtained identifying each $x\in (\partial D_1)\times S_1^1$ with $\mu(x)$.

My idea was to use the fact that the union of the two solid tori, where the boundaries are identified with the $\mu$ induced by $M=Id$ (or, I think, via any homeomorphism between the two boundary tori: is this true?), is in fact $S^3=\partial (D_1\times D_1)=(\partial D_1\times D_2)\cup(D_1\times \partial D_2)$ (recall that $(\partial D_1\times D_2)\cap(D_1\times \partial D_2)$ is exactly $(\partial D_1\times \partial D_2)$, i.e. the boundary of the single torus, which we therefore want to consider as identified via homeomorphism).
So if $M$ is invertible (i.e. $\det M=\pm 1$), i.e. if $\mu$ is an homeomorphism I would think (but I'm far from being sure of that) that $X_\mu$ is homeomorphic to the sphere $S^3$. (Are there any problems in the case $-1$?)
What can be said if $M$ is not invertible (i.e. not injective)? Intuitively, the loops in the boundary are forced to 'count more times' in the process of identification, but this is just an intuition (perhaps wrong) and I would be interested in a formal discussion of the situation.
Thank you in advance!
 A: We first construct a space $Y_\mu$ by attaching the 2-cell $D_1\times p$ to $Z_2=S_2^1\times \partial D_2$, where $p$ is an arbitrary point in $S_1^1$, via the restriction of the map $\mu$. Then, assuming that you use a natural identification of $\partial D_1\times S^1$ with ${\mathbb R}^2/{\mathbb Z}^2$, we obtain that the image of $\partial D_1\times p$ under $\mu$ is homotopic to the loop $M{\mathbf e}_1=(a,c)^t$. In terms of $\pi_1(Z_2)$, this loop equals $\gamma^a$, where $\gamma$ is the generator of $\pi_1(Z_2)$ represented by the oriented loop $S_2^1\times q$, where $q$ is the center of the disk $D_2$. 
Therefore, by the van Kampen's theorem, 
$$
\pi_1(Y_\mu)\cong \pi_1(Z_2)/\langle \gamma^a\rangle \cong \langle\gamma\rangle/ \langle \gamma^a\rangle. 
$$ 
If $a=0$, then this group is $\cong {\mathbb Z}$, while if $a\ne 0$, this group is $\cong {\mathbb Z}_{|a|}$,
the cyclic group of the order $|a|$. Now, attaching the rest of the solid torus $D_1\times S_1^1$ to $Z_2$ will not change the fundamental group since it amounts to attaching a 3-cell to the CW complex $Y_\mu$. 
Thus, the answer is ${\mathbb Z}$ if $a=0$ and ${\mathbb Z}_{|a|}$ otherwise. 
