In Atwood machine system we will have
[tex]a = \frac{m_1 - m_2}{m_1+m_2}*g[/tex]
[tex]0.4 = \frac{m_1 - m_2}{m_1 + m_2}*10[/tex]
[tex]0.4m_1 + 0.4m_2 = 10 m_1 - 10m_2[/tex]
[tex]10.4m_2 = 9.6m_1[/tex]
[tex]1.08m_2 = m_1[/tex]
Also we know the kinetic energy
[tex]\frac{1}{2} m_1v_1^2 +\frac{1}{2}m_2v_2^2 = 87[/tex]
[tex]m_1 + m_2 = 43.5 J[/tex]
now solving the two equations we will have
[tex]m_2 = 21 kg[/tex]
[tex]m_1 = 22.6 kg[/tex]