Cycles of Lanes#370

Cycles of Lanes

1 second
64 megabytes
Very easy

Each of the lanes in the Park of the Polytechnic University of Bucharest connects two of the crossroads (labeled from to ). No pair of crossroads is connected by more than one lane, and it is possible to pass from each crossroad to any other crossroad by a path composed of one or more lanes. A cycle of lanes is called simple if it passes through each of its crossroads exactly once.

The university administration would like to place photos of the winners of the Regional Collegiate Programming Contest on the lanes, making sure that the photos of the winners from the same university are on the lanes of the same simple cycle. Therefore, the administration wants to assign the longest simple cycles to the most successful universities. The problem is to find the length of the longest simple cycle. Fortunately, it turns out that each lane of the park participates in at most one simple cycle (see the Figure).

Input

The first line contains the number of test cases. Each test case starts with a line containing the positive integers and , separated by a space (4 \leq N \leq 4444). Each of the next lines of the test case contains the labels of a pair of crossroads connected by a lane.

Output

For each test case, output a single line containing the length of the maximal simple cycle.

Examples

Example 1

Loading
Loading