Jellyfish#11101

Jellyfish

2 Sekunden
128 Megabyte
Sehr schwer

Everyone knows that at Jagiellonian University we do love plants a lot. We created hundreds of problems about trees, forests and even cacti! Unfortunately, problems about animals are not that popular. Today we want to prove that we love animals as well.

We say that a graph is a jellyfish, if it is a simple connected undirected graph with equal number of vertices and edges. You are given a jellyfish with vertices. For an arbitrary subset of vertices S \subseteq J, we say that is an awesome subset if for every T \subseteq S there exists a connected subgraph of the jellyfish which contains every vertex from and does not contain any other vertex from .

What is the maximum possible size of an awesome subset of ?

Eingabe

The first line contains the number of test cases . The descriptions of the test cases follow.

The first line of each test case contains one integer (3 \le n \le 10^5) - the number of vertices of the jellyfish.

The next lines contain two integers u_i, v_i (1 \le u_i \neq v_i \le n) each, corresponding to the jellyfish edges. It is guaranteed that the given graph is a jellyfish, and every two vertices are connected by at most one edge.

The total number of vertices in all test cases does not exceed 10^6.

Ausgabe

For each test case, output a single integer - the maximum possible size of an awesome subset of the jellyfish.

Beispiele

Beispiel 1

Loading
Loading