#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define vvi vector<vector<int>>
#define mi  map<int,int>
#define mii map<pii,int>
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define sz(x) (int)x.size()
#define all(v) (v).begin(), (v).end()
#define ret(x) return cout<<x,0;
#define rety return cout<<"YES",0;
#define retn return cout<<"NO",0;
#define fl fflush(stdout)   
#define hell 1000000007
#define hell2 998244353 
#define pi 3.14159265358979323846
#define vs vector<string>

int fexp(int a, int b,int m){int ans = 1;while(b){if(b&1)ans=ans*a%m; b/=2;a=a*a%m;}return ans;}
int inverse(int a, int p){return fexp(a, p-2,p);} 

int fac[300005]; //fac[0]=1;fac[1]=1;rep(i,2,100005)fac[i]=(fac[i-1]*i)%hell;

int ncr(int n, int r,int p) { 
    if (r==0) return 1; 
    return (fac[n]*inverse(fac[r],p)%p*inverse(fac[n-r],p)%p)%p; 
}

bool sortby(pii &a,pii &b){
    if(a.ff==b.ff)return (a.ss<b.ss);
    return (a.ff<b.ff);
}

int solve(){
    int n,m,k,x;
    cin>>n>>m;
    int a[m+1]={0},b[n]={0};
    vector<vii> adj(m+1);
    vii v;
    rep(i,0,n){
        int x,y;
        cin>>k>>x;
        a[x]++;
        if(k==2){
            cin>>y;
            a[y]++;
            adj[x].pb({y,i});
            adj[y].pb({x,i});
        }    
        else {
            y=x;
            adj[x].pb({x,i});
        }
        v.pb({x,y});
    }
    int t=0;
    int vis[m+1]={0};
    int viss[n+1]={0};
    rep(i,0,n){
        int x=v[i].ff,y=v[i].ss,ans=i,tt=0;
        if(!vis[x]){
            viss[i]=1;
            tt++;
            queue<int> q;
            int f=0;
            q.push(x);
            vis[x]=1;
            
            if(!vis[y]){
            
                q.push(y);
                vis[y]=1;
            }
            if(a[x]&1||a[y]&1)f=1;
            while(!q.empty()){
                int z=q.front();
                q.pop();
                for(auto zz:adj[z]){
                    if(!viss[zz.ss]){
                        viss[zz.ss]=1;
                        ans=max(ans,zz.ss);
                        tt++;
                    }
                    if(!vis[zz.ff]){
                        //tt++;
                        q.push(zz.ff);
                        vis[zz.ff]=1;
                        if(a[zz.ff]&1)f=1;
                        ans=max(ans,zz.ss);
                    }
                }
            }
            if(!f){
                b[ans]=1;
            //cout<<tt<<" ";
            t+=(fexp(2,tt-1,hell)-1);
            }
            else{
                t+=(fexp(2,tt,hell)-1);
            }
            t%=hell;
        }
    }
    t++;
    t%=hell;
    cout<<t<<" ";
    vi aa;
    rep(i,0,n)if(!b[i])aa.pb(i+1);
    cout<<sz(aa)<<"\n";
    for(auto aaa:aa)cout<<aaa<<" ";
    return 0;   
}

signed main(){
    auto start = high_resolution_clock::now();
    IOS;
    int t=1;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    //cin>>t;
    //fac[0]=1;fac[1]=1;rep(i,2,100005)fac[i]=(fac[i-1]*i)%hell;
    while(t--){
        solve();
        cout<<"\n";
    }
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cerr<<"Time taken:"<<duration.count()/1000000.0<<"seconds"<<"\n";
    return 0;
}