@ajaysabarish,
Haruspex gave you a very good explanation, but using quantities which are conserved provides an easy solution for problems. In case there is a fixed axis of rotation, momentum is not conserved, but the angular momentum does if there is no external torque. If a point mass m performs uniform circular motion with speed v and the radius is r, its velocity changes all the time, so is its momentum, but its angular momentum L=mrv is constant.
I hope you will learn about angular momentum soon.
The angular momentum with respect to a point is m
rX
v, where
r is the position vector and
v is the velocity. X means cross-product, It is easy to calculate as multiplying the speed with the distance of the lline of velocity from the axes of rotation. The sign is positive if the motion corresponds to an anti-clockwise rotation about the axis and negative when it is clock-wise. The same way as it is with the torque, I hope you are familiar with it, or you will learn it soon.
The angular momentum of a system is conserved if there are no external torques or they can be ignored during the short time of collision. It is the case here, as the only torques present are because of gravity.
If the pulley has radius r, the string is at distance r from the rotation axis. If the falling body falls along the string with speed v, its angular momentum is Li = mrv. As the other masses are in rest, Li is the total initial angular momentum of the system. Li is positive as it corresponds anti-clockwise rotation of the pulley.
After the collision, all masses move with speed u, the sticked together masses downward with angular momentum 2mur, and the other mass upward on the other side. It also corresponds to anticlockwise rotation of the pulley, so that angular momentum is also positive, .So the final angular momentum is Lf=2mru+mru=3mru.
Lf=Li so 3mru=mrv. Divide the equation with r. You see, no need to imagine that the masses are arranged horizontally and no need to work with the impulse.