Tree !#12252

Tree !

1 second
256 megabytes
Medium

"Tree of Life."

TheFatRat - Back One Day

Polycarp has a tree of size . An edge of the tree is called balanced, if and only if it forms trees with the same number of ^\dagger leaves when cut. Polycarp wants to find the number of balanced edges in the tree, but he is not a great programmer. Therefore, he is calling you for help. Find the number of balanced edges in the tree.

Leaf is a node connected to exactly node by an edge.

Input

The first line contains a single integer (1 \le t \le 10^4) – the number of tests.

The first line of each test contains a single integer (1 \le n \le 10^5) – the number of nodes in the tree.

The next n-1 lines contain two integers (1 \le u,v \le n, u \ne v) – meaning that there is an edge between nodes and .

It's guaranteed that the sum of over all tests doesn't exceed 2\cdot 10^5.

Output

For each test, output a single integer, the number of balanced edges. If there are none, output .

Examples

Example 1

Loading
Loading

Note

In the first test case:

The only edge is balanced, as it forms two trees with leaves each when cut.

In the second test case:

You can remove the edge and get two trees with leaves each.

In the third test case:

There are no balanced edges, as none form 2 trees with an equal number of leaves after cutting.

Scoring

  1. Subtask ( points) : (n \le 10)

  2. Subtask ( points) : It's guaranteed that the tree is a line.

  3. Subtask ( points) : (\sum n \le 2100)

  4. Subtask ( points) : No additional constraints.