how do the lungs and the heart work together?