the equation of the reaction before balancing is
a0NH₄Cl + a1Ag₃PO₄ → a2AgCl + a3(NH₄)₃PO₄
PO₄³⁻ ion is balanced.
on the left side, theres 1 (NH₄⁺) ion and right side 3 (NH₄⁺) ions. Therefore if we put the coefficient for NH₄Cl, we will obtain the following equation
3 NH₄Cl + a1Ag₃PO₄ → a2AgCl + a3(NH₄)₃PO₄
3 Ag⁺ ions on the left side and 1 Ag⁺ ion on the right side, so if we put the coefficient of AgCl as 3, following equation obtained
3 NH₄Cl + a1Ag₃PO₄ → 3 AgCl + a3(NH₄)₃PO₄
Cl⁻ ions are also balanced now, 3 on either side.
a1 and a3 are 1 as those compounds are as it is, so coefficient is 1 for both
balanced equation is as follows
3 NH₄Cl + Ag₃PO₄ → 3 AgCl + (NH₄)₃PO₄
coefficients are
a0 - 3
a1 - 1
a2 - 3
a3 - 1