Suppose a diathermic movable piston separates an adiabatic container into $2$ parts. Thermodynamic parameters of gases in the two parts are $p_1,v_1,t_1$ and $p_2,v_2,t_2$. We assume quasi static processes.

If we apply first law of thermodynamics to these two parts separately and take into account that heat lost by one is gained by the other and change in internal energy of one gas is the negative of the change in internal energy of the other gas, the work done by one should be the negative of the work done by other. 

 1. How are work done by the two gases equal in magnitude if the pressures of the two gases are unequal throughout till the end of the process? 

 2. My teacher said that FLT can be applied to both the gases separately as well as together. I’m confused about how I can apply it to both gases simultaneously. 

Any help in clearing my confusion will be very appreciated.