(b) If $f_{1}$ is the contact force in the first case, then
$f_{1} = (2m)$ (acceleration)
$= 2m \times \frac{P}{5m} = \frac{2P}{5}$
If $f_{2}$ is the contact force in the second case, then
$f_{2} = (3m)$ (acceleration)
$= 3m \times \frac{P}{5m} = \frac{3P}{5}$
Required ratio is $\frac{2P}{5}:\frac{3P}{5}$ or 2 : 3
Note that the total acceleration of the system is the same as the acceleration of mass 2$m$ or mass 3$m$