SP9126 GCPC11J - Time to live
Description
As you might know, most computer networks are organized in a tree-like fashion, i.e. each computer is reachable by each other computer but only over one, unique path.
The so-called _Time to live_ (TTL) specifies after how many hops a network packet is dropped if it has not reached its destination yet. The purpose of the TTL is to avoid situations in which a packet circulates through the network caused by errors in the routing tables.
The placement of a router that connects the network to another network is optimal when the maximal needed TTL for packets that are sent from this router to any other computer within the same network is minimal. Given a network as specified above, you should calculate the maximal needed TTL in this network if you can select the computer that should be used as router.
Input Format
The first line of the input consists of the number of test cases _c_ that follow (_1 ). Each test case starts with a line specifying _N_, the number of computers in this network (_1 < N ). Computers are numbered from 0 to _N-1_. Then follow _N-1_ lines, each specifying a network connection by two numbers _a_ and _b_ which means that computer _a_ is connected to computer _b_ and vice versa, of course (_0 ).___
Output Format
For each test case in the input, print one line containing the optimal TTL as specified above.