I know the following facts: $\text{SL}_2(\mathbb{Z})$ is generated by everyone's favorite matrices
\begin{equation*}
S = 
\begin{pmatrix}
0 & -1 \\
1 & 0 
\end{pmatrix}
\end{equation*}
and
\begin{equation*}
T = 
\begin{pmatrix}
1 & 1 \\
0 & 1 
\end{pmatrix}
\end{equation*}
and $\text{SL}_2(\mathbb{Z})$ acts transitively on $\mathbb{P}^1(\mathbb{Q})$.  

I have been told that the answer to the following questions have something to do with continued fraction expansions, but I would like to find a reference/pointers to the particulars.  

(1) How do I write a given matrix $A \in \text{SL}_2(\mathbb{Z})$ in terms of $S$ and $T$? 

(2) For a given $p/q \in \mathbb{Q}$, how do I find an element $A \in \text{SL}_2(\mathbb{Z})$ with $A(\infty) = p/q$?