#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define lowbit(x) (x)&(-x) #define REP(i,a,b) for(int i=(a);i<=(b);i++) #define PER(i,a,b) for(int i=(a);i>=(b);i--) #define RVC(i,S) for(int i=0;i<(S).size();i++) #define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next) using namespace std; typedef long long LL; typedef pair pii; template inline void read(T& num) { bool start = false, neg = false; char c; num = 0; while ((c = getchar()) != EOF) { if (c == '-') start = neg = true; else if (c >= '0' && c <= '9') { start = true; num = num * 10 + c - '0'; } else if (start) break; } if (neg) num = -num; } /*-------- Header File --------*/ int n, x[105], y[105], con[101][101], cnt; vector G[101]; bool vis[101]; void color(int x) { if (vis[x]) return; //printf("%d,", x); vis[x] = true; ++cnt; RVC(i, G[x]) if (con[x][G[x][i]]) color(G[x][i]); } int main() { int T; read(T); while (T--) { memset(con, 0, sizeof(con)); read(n); REP(i, 1, n) G[i].clear(); REP(i, 1, n + 1) { read(x[i]); read(y[i]); G[x[i]].push_back(y[i]); G[y[i]].push_back(x[i]); ++con[x[i]][y[i]]; ++con[y[i]][x[i]]; } int ans = 0; REP(i, 1, n + 1) { --con[x[i]][y[i]]; --con[y[i]][x[i]]; memset(vis, 0, sizeof(vis)); //printf("del %d,%d\n", x[i], y[i]); cnt = 0; color(1); //printf("\n%d\n", cnt); if (cnt == n) ++ans; ++con[x[i]][y[i]]; ++con[y[i]][x[i]]; } REP(i, 1, n) REP(j, i + 1, n + 1) { --con[x[i]][y[i]]; --con[y[i]][x[i]]; --con[x[j]][y[j]]; --con[y[j]][x[j]]; //printf("del %d,%d %d,%d\n", x[i], y[i], x[j], x[j]); memset(vis, 0, sizeof(vis)); cnt = 0; color(1); //printf("\n%d\n", cnt); if (cnt == n) ++ans; ++con[x[i]][y[i]]; ++con[y[i]][x[i]]; ++con[x[j]][y[j]]; ++con[y[j]][x[j]]; } printf("%d\n", ans); } return 0; }