Given a connected simple undirected graph with $n$ vertices and $m$ edges, where the $i$-th edge ($1 \le i \le m$) connects vertices $u_i$ and $v_i$ ($1 \le u_i, v_i \le n$).
Initially, all vertices are white. Two players, Alice and Bob, play a game on this graph with the following rules:
- Initially, Alice chooses a vertex $x$ ($1 \le x \le n$) and colors it black.
- Subsequently, Bob performs several rounds of operations:
- In each round, Bob can choose one vertex or two vertices, provided that all chosen vertices are currently white and each chosen vertex has at least one neighbor that is already black.
- Bob colors the chosen vertices black.
- The game ends when all vertices are colored black. The time consumed by Bob is the number of rounds he performs.
Bob wants the game to end as quickly as possible, while Alice wants the game to end as slowly as possible. Assuming both players play optimally, determine the number of rounds after which the game will end.
Input
Each test case may contain multiple test sets.
The first line of the input contains an integer $T$, representing the number of test cases.
For each test case:
The first line contains two integers $n$ and $m$, describing the number of vertices and edges in the graph.
The next $m$ lines each contain two integers $u, v$, describing an edge.
It is guaranteed that there are no multiple edges or self-loops, and the graph is a connected undirected graph.
Output
For each test case, output a single integer representing the answer.
Examples
Input 1
3
4 3
1 2
2 3
3 4
4 6
1 2
1 3
1 4
2 3
2 4
3 4
5 5
1 2
2 3
3 4
4 5
5 1
Output 1
3
2
2
Note
For the first test case, one optimal strategy for Alice is to choose vertex $1$ and color it black. Then:
- In the first round, Bob chooses vertex $2$ and colors it black.
- In the second round, Bob chooses vertex $3$ and colors it black.
- In the third round, Bob chooses vertex $4$ and colors it black.
A total of $3$ rounds are required.
For the second test case, one optimal strategy for Alice is to choose vertex $1$ and color it black. Then:
- In the first round, Bob chooses vertices $2, 3$ and colors them black.
- In the second round, Bob chooses vertex $4$ and colors it black.
A total of $2$ rounds are required.
For the third test case, one optimal strategy for Alice is to choose vertex $1$ and color it black. Then:
- In the first round, Bob chooses vertices $2, 3$ and colors them black.
- In the second round, Bob chooses vertices $4, 5$ and colors them black.
A total of $2$ rounds are required.
Subtasks
For all data, $2 \le n \le 3 \times 10^5$, $n-1 \le m \le 3 \times 10^5$, $1 \le u_i, v_i \le n$.
For all data, $\sum n \le 3 \times 10^5$, $\sum m \le 3 \times 10^5$.
It is guaranteed that the input graph is a simple connected undirected graph.
| Subtask ID | $\sum n \le$ | $\sum m \le$ | Special Property | Score |
|---|---|---|---|---|
| $1$ | $16$ | $40$ | None | $6$ |
| $2$ | $1\,000$ | $2\,000$ | $10$ | |
| $3$ | $10^5$ | $10^5$ | $m=n-1$ | $18$ |
| $4$ | $m = n$ | $13$ | ||
| $5$ | $3 \times 10^5$ | $3\times 10^5$ | Diameter of the graph is $1$ to $n$ | $21$ |
| $6$ | None | $32$ |