Solution (source code)

= Solution

\b[True.] If $p(a,a')=p(b,b')$, then $a'=b'$, so $f(a)=g(a')=g(b')=f(b)$. Injectivity of $f$ gives $a=b$.