Lets start writing equations for both the blocks
For m1 : -
m1g−T=m1a
For m2: -
T−m2g=m2a
Given that a=8g
On substituting a in both equations and adding them we get ,
m1g− m2g = m1(8g)+m2(8g)
(m1− m2)g = (m1+m2)(8g)
m1+m2(m1− m2)=81
On dividing Numerator and denominator with m2
(m2m1+1)(m2m1−1)=81
consider m2m1 as x and solve for x
(x+1)(x−1)=81
(x−1)=81(x+1)
x−81x=81+1
87x=89
x=79