To have an ahead on collision the blocks should traverse in opposite directions. The speed gained by each of the blocks in opposite directions under gravity through the frictionless smooth track is given by :
v^2 = 2gs = 2*9.81*5. Or
(i) v = 9.904544412m/s is the speed in opposite directions before impact. m2 has +9.90..m/s anticlocwise and m1 has -9.90..m/s clock wise say.
ii) The velocities of the blocks after collision is given by:
v1f (final velocity of m1 ) = [2m2b+(m1-m2)a]/(m1+m2) where a and b are the initial velocities of the blocks m1 and m2, in this case -v and +v
=[2*4v+(2-4)(-v)]/(2+4) = 10v/6 = 5v/3 = (5*9.904544412m/s)/3 = +16.5076 m/s anti clockwise.
v2f (final velocity v) = [2m1a+(m2-m1)a]/(m1+m2)=2*2(-v)+(4-2)V]/(2+4) = (-4+2)v/6 = -v/3 = -9.904544412m/3 m/s = 3.3015 clockwise.
The first block with speed 16.5076m/s could move a height h meter, given by 2gh = 16.5076..^2 Or h = 16.5076^2/(2g) = 13.8889 meter of height , where g is the acceleration due to gravity and is assumed 9.81m/s^2
The second block could go as high as 3.3015^2/(2g) = 0.5556 meter of height.