#include using namespace std; #define repd(i,a,b) for (ll i=(a);i<(b);i++) #define rep(i,n) repd(i,0,n) #define all(x) (x).begin(),(x).end() template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } typedef long long ll; typedef pair P; typedef vector vec; using Graph = vector>; const long long INF = 1LL<<60; const long long MOD = 1000000007; int main() { ios::sync_with_stdio(false); cin.tie(0); ll n,m; cin>>n>>m; vec a(m); vec b(m); rep(i,m){ ll x;cin>>x; rep(j,x){ ll y;cin>>y; y--; a[i]^=(1<>b[i]; } ll cnt=0; vec memo(n,-1); rep(i,n){ ll idx=-1; repd(j,cnt,m){ if((a[j]>>i)&1){ idx=j; break; } } if(idx==-1){ memo[i]=0; continue; } swap(a[idx],a[cnt]); swap(b[idx],b[cnt]); repd(j,cnt+1,m){ if((a[j]>>i)&1){ a[j]^=a[cnt]; b[j]^=b[cnt]; } } cnt++; } repd(i,cnt,m){ if(b[i]!=0){ cout<<-1<=0;i--){ if(memo[i]==0)continue; cnt--; for(ll j=i+1;j>j)&1){ b[cnt]^=memo[j]; } } memo[i]=b[cnt]; } rep(i,n)cout<