First law of thermodynamics deals with