#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include using namespace std; typedef long long ll; ll inve(ll x){return x;} ll det(vector> a){ int i,j,k,n = a.size(); ll ret = 1; // for(i=0;i=mod) (a[i][j]) %= mod; // } // } for(i=0;i> t; while(t){ t--; int i,j,n,mod; cin >> n >> mod; vector> a(n); for(i=0;i> a[i][j]; } if(mod!=2){ cout << 0 << "\n"; }else{ int num = 0; vector x,y; for(i=0;i> c(n - num); vector x_use(n,true),y_use(n,true); for(i=0;i