Act of Random Kindness (Hard)

Limits: 1s, 512 MB

Sammy and Meera liked adventures a lot. Once in a while they used to set out adventures. This time to carry out their adventure, Sammy decided to choose two cities from a map and help all the poor people on their way starting from one of them to the other. But to choose the starting and ending location, Sammy needed to know the number of ways to choose two of such locations from the map. As he remains busy solving critical problems about the Life, the Universe, and Everything, he decided to let other people solve these smaller problems.

This is a companion discussion topic for the original entry at