#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; //#pragma comment(linker, "/STACK:1024000000") #define LL long long const int mod=1e9+7; const int INF=0x3f3f3f3f; const double eqs=1e-9; const int MAXN=150010; int u[110],v[110]; int f[110]; bool Judge(int n) { int num = 0; for(int i = 1; i <= n; i++) if(f[i] == i) num++; if(num == 1) return true; return false; } int Find(int x) { return x == f[x] ? x : f[x] = Find(f[x]); } void Init(int n) { for(int i=0;i<=n;i++) f[i] = i; } void Link(int a, int b) { int fx = Find(a); int fy = Find(b); if(fx != fy) f[fx] = fy; } int main() { int T; scanf("%d",&T); while(T--) { int n; int ant = 0; scanf("%d",&n); for(int i=0; i<=n; i++) { scanf("%d %d",&u[i],&v[i]); } for(int i=0; i