Two Blocks and Two Pulleys

A block of mass m_1 is attached to a massless, ideal string. This string wraps around a massless pulley and then wraps around a second pulley that is attached to a block of mass m_2 that is free to slide on a frictionless table. The string is firmly anchored to a wall and the whole system is frictionless.

Assuming that a_2 is the magnitude of the horizontal acceleration of the block of mass m_2, what is T , the tension in the string? Express the tension in terms of m_2 and a_2

I figured out the T to be (m_2*a_2)/2

but got stuck on the next question

Given T, the tension in the string, calculate a_1, the magnitude of the vertical acceleration of the block of mass . Express the acceleration magnitude a_1 in terms of m_1,g , and T.

I know there was a post like this, but the answer wasn't given in T...
Thanks alot again...