The center of mass (CM) cannot shift position. Therefore, the CM of the system must remain the same before and after the exchange.
The equation of the position of the CM is given by:
xcm=mAxA+mBxB+mCxCmA+mB+mC+M
Before the exchange: xcm1=40(−2)+50(0)+60(2)40+50+60+90=16m
After the exchange: xcm2=60(−2)+50(0)+40(2)40+50+60+90=−16m
Therefore, mass B will shift by: xcm1−xcm2=13m towards the right.