SP7563 HISIX - Hi6
Description
"I read somewhere that everybody on this planet is separated by only six other people. Six
Input Format
The first line contains an integer T, which specifies the number of test cases. Then, T test case descriptions will follow. Each test case will start with a line with one positive integer, N meaning the number of connections. The next N lines will contain the following pattern:
meaning that person "" is connected with the person "" by making D connections and viceversa. Note that both persons can know each other by a lower degree of separation using other connections.
Output Format
For each input case you must print the string "Case #i: ", where i is the test case number, starting from 1, following by the maximum degree of separation between the specified people. If there is someone that cannot connect to another person, print "INFINITE" instead.