Lagrange-mesh calculations of excited states of three-body atoms and molecules