int@n,@m,@a[n][n],b[n]; rep(y,n){ if(sum[x,0,n](a[y][x])!=m){ wt(-1); exit(0); } } rep(x,n){ if(sum[y,0,n](a[y][x])!=m){ wt(-1); exit(0); } } rep(m){ ull c=0; rep(y,n){ rep(x,n){ if(!(c&1<