func_code_string: #include <bits/stdc++.h>   using namespace std;   const int M = 1200000;   const int inf = 0x3f3f3f3f;   int n, m, k;   vector<int> g[M];   int ans;   int dfs(int u, int f) {     vector<int> v = {0, 0};     for (int to : g[u]) {       if (to == f) continue;       v.push_back(dfs(to, u));     }     sort(v.begin(), v.end());     reverse(v.begin(), v.end());     int sz = g[u].size();     ans = max(ans, v[0] + v[1] + sz + 1);     return v[0] + sz - 1;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     for (int _ = (1); _ <= (t); ++_) {       cin >> n;       int u, v;       for (int i = (1); i <= (n); ++i) g[i].clear();       for (int i = (2); i <= (n); ++i) {         cin >> u >> v;         g[u].push_back(v);         g[v].push_back(u);       }       ans = 0;       dfs(1, 1);       cout << ans << endl;     }     return 0;   }   