Okay, here we go.

When m1 is at the top of m2 we know that the y component of the velocity of m1 is 0 m/s. At this point in time the horizontal component of m1's velocity must be the same as the velocity of m2, because m1 is about to change direction relative to the motion of m2. Now, m1's momentum is not conserved in the y direction but it is conserved in the x, so we have at this point in time:

$\displaystyle m_2u = m_1 v + m_2 v$

(The velocity of m1 is all in the x direction at this point, so I'm just calling the x component of v1, v.)

We also know that energy is conserved, so when m1 reaches it's max height we have that

$\displaystyle \frac{1}{2}m_2u^2 = \frac{1}{2}m_1v^2 + \frac{1}{2}m_2v^2 + m_1gh$

So using the momentum equation we get

$\displaystyle v = \frac{m_2u}{m_1 + m_2}$

and plugging this into the energy equation:

$\displaystyle \frac{1}{2}m_2u^2 = \frac{1}{2}(m_1 + m_2) \left ( \frac{m_2u}{m_1 + m_2} \right ) ^2 + m_1gh$

$\displaystyle \frac{1}{2}m_2u^2 = \frac{1}{2} \left ( \frac{m_2^2}{m_1 + m_2} \right ) u^2 + m_1gh$

which you can solve for u from there.

-Dan