Let $R$ be a ring. Prove that a sequence of left $R$-modules and homomorphisms $$0 \to N_1 \xrightarrow{f} N_2 \xrightarrow{g} N_3$$
is exact if and only if for all left $R$-modules $M$ sequence $$\hom_R(M, N_1) \xrightarrow{\bar f} \hom_R(M, N_2) \xrightarrow{\bar g} \hom_R(M, N_3) \to 0$$
is an exact sequence of abelian groups, where mappings $\overline{f} : \operatorname{Hom_{R}}(M,N_1)\rightarrow \operatorname{Hom_{R}}(M,N_2)$ and $\overline{g} : \operatorname{Hom_{R}}(M,N_2)\rightarrow \operatorname{Hom_{R}}(M,N_3)$ are given by formulas $$\overline{f}(\phi)=f \circ \phi$$ and $$\overline{g}(\psi)=f \circ \psi$$
I don't have any idea how to solve this problem. Any help please?
The statement "$\hom_R(M, N_1) \xrightarrow{\bar f} \hom_R(M, N_2) \xrightarrow{\bar g} \hom_R(M, N_3)$$ \color {red}{\to 0}$" in your question is false. you can see here, in Hungerford's book "Algebra", the right statement and proof: