func_code_string: #include <bits/stdc++.h>   using namespace std;   int T, n, head[300005], cnt, in[300005], ans, rt;   struct edge {     int to, nxt;   } e[300005 << 1];   void add(int u, int v) {     e[++cnt] = (edge){v, head[u]};     head[u] = cnt;   }   void dfs(int u, int fa, int tot) {     if (tot > ans) ans = tot, rt = u;     for (int i = head[u]; i; i = e[i].nxt) {       int v = e[i].to;       if (v == fa) continue;       dfs(v, u, tot + in[v]);     }   }   int main() {     scanf( %d , &T);     while (T--) {       scanf( %d , &n);       cnt = 0;       for (int i = 1; i <= n; i++) head[i] = 0, in[i] = -1;       for (int i = 1, u, v; i < n; i++) {         scanf( %d%d , &u, &v);         add(u, v);         add(v, u);         in[u]++;         in[v]++;       }       ans = -1;       dfs(1, 0, in[1]);       ans = -1;       dfs(rt, 0, in[rt]);       printf( %d n , ans + 2);     }   }   