#P1695D1. Tree Queries (Easy Version)

    ID: 1032 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 8 Uploaded By: Tags>brute forceconstructive algorithmsdfs and similardpgreedytrees*2200

Tree Queries (Easy Version)

Description

The only difference between this problem and D2 is the bound on the size of the tree.

You are given an unrooted tree with nn vertices. There is some hidden vertex xx in that tree that you are trying to find.

To do this, you may ask kk queries v1,v2,,vkv_1, v_2, \ldots, v_k where the viv_i are vertices in the tree. After you are finished asking all of the queries, you are given kk numbers d1,d2,,dkd_1, d_2, \ldots, d_k, where did_i is the number of edges on the shortest path between viv_i and xx. Note that you know which distance corresponds to which query.

What is the minimum kk such that there exists some queries v1,v2,,vkv_1, v_2, \ldots, v_k that let you always uniquely identify xx (no matter what xx is).

Note that you don't actually need to output these queries.

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1001 \le t \le 100). Description of the test cases follows.

The first line of each test case contains a single integer nn (1n20001 \le n \le 2000)  — the number of vertices in the tree.

Each of the next n1n-1 lines contains two integers xx and yy (1x,yn1 \le x, y \le n), meaning there is an edges between vertices xx and yy in the tree.

It is guaranteed that the given edges form a tree.

It is guaranteed that the sum of nn over all test cases does not exceed 20002000.

For each test case print a single nonnegative integer, the minimum number of queries you need, on its own line.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1001 \le t \le 100). Description of the test cases follows.

The first line of each test case contains a single integer nn (1n20001 \le n \le 2000)  — the number of vertices in the tree.

Each of the next n1n-1 lines contains two integers xx and yy (1x,yn1 \le x, y \le n), meaning there is an edges between vertices xx and yy in the tree.

It is guaranteed that the given edges form a tree.

It is guaranteed that the sum of nn over all test cases does not exceed 20002000.

Output

For each test case print a single nonnegative integer, the minimum number of queries you need, on its own line.

Sample Input 1

3
1
2
1 2
10
2 4
2 1
5 7
3 10
8 6
6 1
1 3
4 7
9 6

Sample Output 1

0
1
2

Note

In the first test case, there is only one vertex, so you don't need any queries.

In the second test case, you can ask a single query about the node 11. Then, if x=1x = 1, you will get 00, otherwise you will get 11.