8553: Maex

内存限制:128 MB 时间限制:3 S
题面:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

You are given a rooted tree consisting of n vertices numbered from 1 to n, and the root is vertex 1.

Vertex i has a natural number weight ai, and no two different vertexes have the same weight.

Define bu=MEX x  vsubtree(u),x=av}.

Unfortunately, ai are not given. Please find out the maximum possible i=1nbi.

TheMEX of a set is the minimum non-negative integer that doesn't belong to the set.

输入格式

The first line contains one integer T(1T10), indicating the number of test cases.

For each test case:

The first line contains one integer n(1n5105), indicating the number of nodes.

In the following n-1 lines, each line contains two interger u,v(1u,vn), indicating an edge (u,v) of the tree.

A guarantee is that forming trees.

输出格式

For each test case: One line with an integer, indicating the maximum possible i=1nbi.

输入样例 复制

3
5
1 2
3 2
1 5
4 1
3
1 2
2 3
1

输出样例 复制

8
6
1