Suppose $a_1, \dots, a_n$ generate an abelian group $A$, and for any abelian group $B$, and any $b_1, \dots, b_n \in B$ we can find a homomorphism $\varphi: A \to B$ given by $\varphi(a_i) = b_i ~ \forall i$. Prove that $A$ is a free abelian group with basis $(a_1, \dots, a_n)$.
My idea: take $B$ to be the free abelian group of rank $n$, and we pick our $b_1, \dots, b_n$ to be a basis for $B$. Then we have a homomorphism that takes each generator of $A$ to a generator of $B$. Moreover, the order of each $b_i$ has to divide the order of the $a_i$, but the $b_i$ have infinite order and thus the $a_i$ have to as well. So we have an epimorphism of $A$ onto $B$. So $A/Ker(\varphi) \cong B$.
This is where I get stuck. I'm not sure how to show that the kernel is trivial. Any help will be appreciated.