There is an undirected graph with vertices and edges. The color of each edge is one of colors through .
The cost of a path from vertex to vertex is defined as follows.
The path may pass through the same vertex or edge multiple times. If the same edge is passed through multiple times, it is counted as many times as it is passed.
Find the minimum cost of a path from vertex to vertex .
The input is given in the following format.
For each test case, print the minimum cost on a single line.
Each case is in the following format.
on the first line is the number of test cases. The first line of each case contains . The -th of the next lines describes an undirected edge of color connecting vertices . Multiple edges are possible. A path from vertex to vertex always exists.
| 2 | 13 | The given graph is a tree. |
| 3 | 35 | ; . |
| 4 | 42 | No additional constraints. |