[guided]Let $b \in B$ be arbitrary. To prove that $S$ generates $B$, we must express this particular element $b$ as an $R$-linear combination of the elements
\begin{align*}
f(a_1), \ldots, f(a_m), b_1, \ldots, b_n.
\end{align*}
The image $g(b) \in C$ can be expanded in the chosen generators of $C$. Thus there exist elements $r_1, \ldots, r_n \in R$ such that
\begin{align*}
g(b) = r_1 c_1 + \cdots + r_n c_n.
\end{align*}
Since each $b_j$ was chosen to satisfy $g(b_j) = c_j$, the element $r_1 b_1 + \cdots + r_n b_n$ is a lift of the displayed expression for $g(b)$. We subtract that lift from $b$ and define
\begin{align*}
b' := b - r_1 b_1 - \cdots - r_n b_n \in B.
\end{align*}
Now compute its image under $g$. Because $g$ is an $R$-[module homomorphism](/page/Module%20Homomorphism), it preserves addition and scalar multiplication, so
\begin{align*}
g(b') = g(b) - r_1 g(b_1) - \cdots - r_n g(b_n).
\end{align*}
Using $g(b_j) = c_j$ for every $j$, this becomes
\begin{align*}
g(b') = g(b) - r_1 c_1 - \cdots - r_n c_n.
\end{align*}
By the choice of $r_1, \ldots, r_n$, the right-hand side is $0$, so $g(b') = 0$. Hence $b' \in \ker g$.
This is the point where exactness at $B$ is used. Exactness gives
\begin{align*}
\ker g = \operatorname{im} f.
\end{align*}
Therefore there exists an element $a \in A$ such that $f(a) = b'$.
Since $a_1, \ldots, a_m$ generate $A$, we may write
\begin{align*}
a = s_1 a_1 + \cdots + s_m a_m
\end{align*}
for some elements $s_1, \ldots, s_m \in R$. Applying the $R$-linearity of $f$ gives
\begin{align*}
b' = f(a) = s_1 f(a_1) + \cdots + s_m f(a_m).
\end{align*}
Substituting the definition of $b'$ and solving for $b$, we get
\begin{align*}
b = s_1 f(a_1) + \cdots + s_m f(a_m) + r_1 b_1 + \cdots + r_n b_n.
\end{align*}
Thus the arbitrary element $b$ lies in the submodule generated by $S$. Since $b \in B$ was arbitrary, $S$ generates $B$. The set $S$ is finite, so $B$ is finitely generated as a left $R$-module.[/guided]