Calculating dipole of different molecules separately

Dear All,
I am trying to calculate dipole moment of several identical molecules in the same simulation box separately, any idea how to calculate it separately for each molecule. how can I identify each molecule separately? any ideas or suggestions

Please have a look at the LAMMPS manual, in particular: