func_code_string: #include <bits/stdc++.h>      using namespace std;   #define  ll long long   #define f first   #define s second   const int N = 2e5+5;      int n , dp[N] , ans;   vector<int> adj[N];      void dfs(int node , int par)   {       vector<int> v;       for(auto ch : adj[node])       {           if (ch==par) continue;           dfs(ch , node);           v.push_back(dp[ch]+1);       }       sort(v.begin() , v.end());          if (v.size())       {           if (node != 1)           {               int mx = v.back() , mn = v[0];               if (adj[node].size() > 1) ans = max(ans , mx+1);                  dp[node] = mn;           }           else           {               int mx = v.back() , mn;               v.pop_back();               if (v.size()) mn = v.back();               else mn = -1; //second maximum                  ans = max(ans , mn+1);               ans = max(ans , mx);               dp[node] = mx;           }       }   }      void clear()   {       ans = 0;       for(int i=1; i<=n; i++)           adj[i].clear() , dp[i] = 0;   }      int main()   {       ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);          int t;       cin >> t;       while(t--)       {           cin >> n;           for(int i=1; i<n; i++)           {               int v,u;               cin >> v >> u;               adj[v].push_back(u) , adj[u].push_back(v);           }              dfs(1,1);              cout << ans <<   n ;              clear();       }             return 0;   }