#include using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } constexpr ll mod=1e9+7; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n,m; cin >> n >> m; vector> basis; for(int i=0;i> a; ll u=0; while(a--){ int b; cin >> b; b--; u+=(1LL<> y; for(auto e:basis){ ll uu=(u^e.first); if(u>uu){ u=uu; y^=e.second; } } if(u>0){ basis.push_back({u,y}); } else{ if(y!=0){ printf("-1\n"); return 0; } } } { vector> n_basis; for(auto e:basis){ ll u=e.first; int y=e.second; for(auto ee:basis){ if(e==ee)continue; ll uu=(u^ee.first); if(u>uu){ u=uu; y^=ee.second; } } if(u>0){ n_basis.push_back({u,y}); } } swap(basis,n_basis); } sort(basis.begin(), basis.end()); vector res(n,-1); for(auto e:basis){ for(int i=n-1;i>=0;i--){ if((1LL<=0;j--){ if((1LL<