Clever girl Meena likes to climb trees. One day her brother Raju, after coming back from school, said to Meena with joyful eyes, “I have seen a big tree with many ripe mangoes. Let's go climb that one!”.
We can think of the mango tree as a connected undirected graph with no cycles and having exactly one path from one node to another. Meena asked Raju to describe the tree. Raju could not memorize the exact structure of the tree but remembered how many nodes were at each level considering the tree is rooted. Suddenly, they both got worried as many trees could satisfy that condition and Meena could not climb trees with all diameters.
In tree data structures, the root node is said to be at level 0, the root node's children are at level 1, and the children of that node at level 1 will be at level 2, and so on. And, the diameter of a tree means the number of nodes on the longest path in the tree.
Can you help Meena and Raju determine how many unique diameter lengths are possible for any such tree?
Suppose that, the mango tree has levels. For each level there exists nodes, -indexed.
You will be given an array of length , -indexed.
Now, to construct from you need to follow the following instructions:
for
for
The first line will contain the number of test cases.
For each test cases, the first line will contain two integers the number of levels in the tree and the length of the array
In the next line, there will be integers denoting the elements of array
It’s guaranteed that,
over all test cases
For each test case, output a single integer denoting the possible number of unique diameter lengths.
Input | Output |
---|---|
1 3 1 2 | 2 |