By the Law of Conservation of Momentum, Initial Momentum=Final Momentum, in a closed system.
Take movement to the right as + and to the left as -
Therefore equate the two as such: Initial (A+B) = final (A+B)
A+B = A+B
(+5x10) + (5x0) = (-2x10) + (5 x Y)
Y indicates speed of B
50+0=-20+5Y
70=5Y
Y=70/5
Y=+14m/s
Therefore Trolley B moves to the right at a speed of 14m/s