# surjective and injective mappings between finitely generated groups

I wonder how much surjective and injective mappings can describe finitely generated groups ? More specificly,if there are two finitely generated groups $A,B$, with a surjective homomorphism $f:A\rightarrow B$,and an injective homomorphism $g:A\rightarrow B$. Then can I say A is isomorphic to B? If so,can f or g be non-isomorphism?If not,under which condition can I derive a isomorphism? Actually,My question has been solved in the case of finitely generated abelian groups.

Let $F_n$ be the free group on $n$ generators. Define $g:F_3 \rightarrow F_2$ as the map which sends the third generator to identity and preserves the other two. This is a surjective morphism. There's also an injective morphism: send the three generators of $F_3$ to $b, aba^{-1}, a^2ba^{-2}$. Notice that this is not a surjection; for example, $a$ is not in the image.
So you have an surjective mapping $f:A \rightarrow B$ and an injective mapping $g:A \rightarrow B$. Ignoring the fact that A and B are finitely generated Abelian groups, what can we say about A and B as sets? This may give an answer to your question.