From the side ramp here of the heat engine, we can see that that's the case. The energy that comes from the hot body, some of that energy goes into doing work, expanding the piston increase, increasing the volume. And some of that goes into the cold body, decreasing the temperature as the piston moves back into its original position, thereby keeping the temperature constant. Okay, we know by conservation of energy that the input energy equals the output energy. That means QH, which means the energy input is equal to QC, the energy transferred into the cold body plus the work done by the system or by the molecules within the system. And this directly correlates the first law of thermodynamics.