It is shown that the lattice of all the congruences on all the subgroups (i.e. the lattice of all weak congruences) of a group is modular if and only if the group is Hamiltonian (this is the solution of a problem stated in [4] ]). It is also proved that a group is Hamiltonian if and only if its diagonal relation is an exceptional element in the above-mentioned lattice.