#include #include #include using namespace std; int f[1000005],s[1000005]; int gf(int x){ if (f[x]==x) return x; f[x]=gf(f[x]); return f[x]; } int main(){ int tt;scanf("%d",&tt); for (;tt--;){ int n;scanf("%d",&n); for (int i=1;i<=n;i++) f[i]=i,s[i]=1; for (int i=1;i