Both masses are accelerated, one up and one across, but both have an acceleration of a. Since it is a pulley system, they both have the same acceleration. Let their acceleration be a. Two equations can be set up for this, one for the 5kg block and one for the 8kg block.
So let m1 (the mass of...