The following is the first part of Proposition 2.9 in "Introduction to Commutative Algebra" by Atiyah & Macdonald.
Let $A$ be a commutative ring with $1$. Let $$M' \overset{u}{\longrightarrow}M\overset{v}{\longrightarrow}M''\longrightarrow 0\tag{1} $$ be sequence of $A$-modules and homomorphisms. Then the sequence (1) is exact if and only if for all $A$-modules $N$, the sequence $$0\longrightarrow \operatorname{Hom}(M'', N) \overset{\overline{v}}{\longrightarrow}\operatorname{Hom}(M, N)\overset{\overline{u}}{\longrightarrow}\operatorname{Hom}(M', N) \tag{2} $$ is exact.
Here, $\overline{v}$ is the map defined by $\overline{v}(f)=f\circ v$ for every $f\in\operatorname{Hom}(M'', N)$ and $\overline{u}$ is defined likewise.
The proof one of direction, namely $(2)\Rightarrow (1)$ is given in the book, which I am having some trouble understanding. So assuming (2) is exact sequence, the authors remark that "since $\overline{v}$ is injective for all $N$, it follows that $v$ is surjective". Could someone explain why this follows?
Given that $\overline{v}$ is injective, we know that whenever $f(v(x))=g(v(x))$ for all $x\in M$, we have $f=g$. I am not sure how we conclude from this surjectivity of $v$.
Thanks!