#include using namespace std; const int mo=998244353; const int N=2011; vector e[N]; int d[N],n; void bfs(int S){ queue q; memset(d,0,sizeof d); d[S]=1; q.push(S); while(!q.empty()){ int x=q.front(); q.pop(); for(int y:e[x]){ if(!d[y]){ d[y]=d[x]+1; q.push(y); } } } } int f[N]; int main(){ #ifdef flukehn freopen("f.in","r",stdin); #endif int T; cin>>T; while(T--){ cin>>n; for(int i=1;i<=n;++i)e[i].clear(); for(int i=1;i>x>>y; e[x].push_back(y); e[y].push_back(x); } int mx=0; long long tot=0; for(int i=1;i<=n;++i){ bfs(i); for(int j=1;j<=n;++j){ if(d[j]>mx) mx=d[j], tot=0; } //for(int j=1;j<=n;++j)cerr<