Characterization of optimal shapes and masses through Monge-Kantorovich equation