In both cases m1>m2. Therefore, m1 will accelerate downward and m2 will accelerate upward.
For m1,
m1g−T=m1a
For m2,
T−m2g=m2a
Adding the above equations we get,
a=m1+m2m1−m2g
⇒a1=m1+m2m1−m2g=2m2+m22m2−m2g=3g
and
⇒a2=m1+m2m1−m2g=3m2+m23m2−m2g=2g
⇒a2a1=32