One of the post services companies in a country plans to designate one of its branches as the central office. The company has a branch in each and every city in the country. The cities are so connected by roads that to go from any city to another, there is a unique sequence of roads to take. The central office is in charge of dispatching parcels to all other branches. For this purpose, a car is used that starting from the central office goes through all cities to the last one delivering their parcels. As time is always a top priority in post services, the company’s administration wants a designation which minimizes dispatching times. If the car travels the distance between any two adjacent cities in one hour, calculate the minimum total dispatching time Tm, considering the optimal designation. Input The first line of input contains an integer T ≤ 100 denoting the number of test-cases. Each test-case begins with an integer 1 ≤ N ≤ 10,000 denoting the number of cities (numbered from 1 to N) of the country, on a separate line. The i-th line of the following N lines starts with the number Mi of the cities adjacent to the i-th city followed by Mi integers, the neighboring city indexes. Output For each test-case, output on a single line the minimum dispatching time Tm. Sample Input 2 2 12 11 5 3234 11 215 11 13 Sample Output 1 5