Gildong has put one nibble at each crossing point of the recreation center. Presently Gildong will give Badugi a mission to eat the snacks as a whole. Badugi begins at the 1-st convergence, and he will move by the accompanying guidelines: Badugi searches for tidbits that are as near him as could be expected. Here, the distance is the length of the most limited way from Badugi's present area to the convergence
Correct answer will be upvoted else Multiple Downvoted. Computer science.
Gildong has put one nibble at each crossing point of the recreation center. Presently Gildong will give Badugi a mission to eat the snacks as a whole. Badugi begins at the 1-st convergence, and he will move by the accompanying guidelines:
Badugi searches for tidbits that are as near him as could be expected. Here, the distance is the length of the most limited way from Badugi's present area to the convergence with the bite. Notwithstanding, Badugi's feeling of smell is restricted to k meters, so he can just find tidbits that are not exactly or equivalent to k meters from himself. In the event that he can't track down any such bite, he bombs the mission.
Among every one of the bites that Badugi can smell from his present area, he picks a tidbit that limits the distance he really wants to go from his present convergence. In case there are various such bites, Badugi will pick one self-assertively.
He rehashes this cycle until he eats all n snacks. From that point onward, he needs to find the 1-st convergence again which additionally should be not exactly or equivalent to k meters from the last nibble he recently ate. If he figures out how to track down it, he finishes the mission. In any case, he bombs the mission.
Lamentably, Gildong doesn't have a clue about the worth of k. In this way, he needs you to observe the base worth of k that makes it feasible for Badugi to finish his central goal, if Badugi moves ideally.
Input
Each test contains at least one experiments. The primary line contains the number of experiments t (1≤t≤104).
The primary line of each experiment contains one integer n (2≤n≤2⋅105) — the number of convergences of the recreation center.
The following n−1 lines contain two integers u and v (1≤u,v≤n, u≠v) every, which implies there is a street between crossing point u and v. All streets are bidirectional and unmistakable.
It is ensured that:
For each experiment, for each an and b (1≤a,b≤n), it is feasible to get to the b-th crossing point from the a-th convergence.
The amount of n in all experiments doesn't surpass 2⋅105.
Output
For each experiment, print one integer — the base conceivable worth of k with the end goal that Badugi can finish the mission..
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images