func_code_string: #include<bits/stdc++.h>   #define ll long long   using namespace std;      int k;   int dfs(int v, int p, vector<vector<int>> &viz){    int t=-1;    vector < int > pos;    for(auto u: viz[v]){     if(u==p) continue;     int w=dfs(u,v,viz);     pos.push_back(w);     if(t==-1) t=w+1;     t = min(t,w+1);    }    sort(pos.begin(), pos.end());    int n = pos.size();    if(v==1){     if(n>=1) k = max(k, pos[n-1]+1);     if(n>=2) k = max(k, pos[n-2]+2);    }    else{     if(n>=2) k = max(k, pos[n-1]+2);    }    if(t==-1) t=0;    return t;   }      int main(){    ios::sync_with_stdio(false);      cin.tie(0);      int t;      cin >> t;      while(t--){       int n;       cin >> n;       k=0;       vector < vector <int> > viz(n+1);       for(int i=0; i<n-1; i++){        int a, b;        cin >> a >> b;        viz[a].push_back(b);        viz[b].push_back(a);     }     dfs(1,0,viz);     cout << k << endl;    }   }   