Warshall reachability

Find out which towns you can reach from each town, even if you change roads along the way. Save the answers in a table so you can look up a pair of towns later.

Allow one more intermediate town. If A reaches it and it reaches B, mark A → B with a one. Every town reaches itself in zero steps.

Time is O(V³), space is O(V²).