In a perfectly inelastic collision:

M1*v1 + M2*v2 = (M1 + M2)*vf

Here M1 and M2 are the masses of the bodies colliding, v1 and v2 are their initial velocity and vf is their final velocity.

Now, in the problem it is given that the body of mass 16 kg is travelling at 5 m/s towards the right. It collides with a body of mass 4 kg travelling at 5 m/s towards the rest.

Therefore we can use

M1*v1 + M2*v2 = (M1 + M2)*vf

=> vf = (M1*v1 + M2*v2)/(M1 + M2)

=> vf = (16*5 - 4*5)/20

=> vf = 60/20

=> vf = 3 m/s

**The final body made up of the bodies that collided with each other moves at 3 m/s towards the right.**