We are given the complete reaction:
 3 H2(g) + N2(g) → 2 NH3(g)
  
 First let us convert mass to moles.
 moles H2 = 5.22 kg / (2 kg/kmol) = 2.61 kmol H2
 moles N2 = 31.5 kg / (28 kg/kmol) = 1.125 kmol N2
  
 Then we find for the limiting reactant. The limiting reactant is the one who has lower (moles/coefficient) ratio.
 H2 = 2.61 / 3 = 0.87
 N2 = 1.125 / 1 = 1.125
  
 Hence the H2 is the limiting reactant so we should base the calculation of NH3 from it. We see that 2 moles of NH3 is produced for every 3 moles of H2, therefore:
 moles NH3 = 2.61 kmol H2 * (2 kmol NH3 / 3 kmol H2) = 1.74 kmol
  
 The molar mass of NH3 is 17 kg/kmol, therefore the mass NH3 is:
 mass NH3 = 1.74 kmol * 17 kg/kmol
 mass NH3 = 29.58 kg