Solution (source code)

= Solution

Suppose $g(b)=g(b')$. Since $f$ is <surjective>, choose $a,a'\in A$ with $f(a)=b$ and $f(a')=b'$. Then $(g\circ f)(a)=(g\circ f)(a')$, so <injectivity> gives $a=a'$ and therefore $b=b'$. Thus $g$ is <injective>. The use of <surjectivity> is what makes every point of $B$ accessible to this argument.