Sort the file alphabetically.
A, B A, B
C, D -> C, D
F, E D, E
D, E E, F
We create a list of sets, each set represents connected cities.
For each city of the pair, loop through the set to see if the set contains
one of cities, if it does, then add another city name into set. If all the
sets doesn't contain either of city, create a new set and add those two city
names into it.
To see if two cities are connected, loop through the set to see if set have
both city names.