#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e9+7;
ll MOD = 998244353;
typedef pair<int,int> ii;
#define iii pair<ll,ii>
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Good Bye 2020
vector<vll>adj;
int main(void){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,m;
    cin>>n>>m;
    vector<vll>vs;
    ll posoi = 0;
    ll ans = 1;
    bool exo[m] = {0};
    set<ll>ex,ex2;
    f(i,0,n){
        ex.insert(i+1);
        ex2.insert(i);
        ll k;
        cin>>k;
        vs.pb(vll());
        f(j,0,k){
            ll a;
            cin>>a;
            vs.back().pb(a);
        }
        posoi += vs[i].size() == 1;
        if(vs[i].size() == 1){
            exo[vs[i][0]] = 1;
            ex2.erase(i);
        }
    }
    bool ok = 1;
    while(!ex2.empty()){
        ok = 1;
        while(ok){
            ok = 0;
            set<ll>fk;
            for(auto i:ex2){
                ll posa = exo[vs[i][0]] + exo[vs[i][1]];
                if(posa == 2){
                    ex.erase(i+1);
                    fk.insert(i);
                }
                else if(posa == 1){
                    exo[vs[i][0]] = exo[vs[i][1]] = 1;
                    fk.insert(i);
                    posoi++;
                    ok = 1;
                }
            }
            for(auto x:fk){
                ex2.erase(x);
            }
        }
        if(!ex2.empty()){
            ll pos = (*ex2.begin());
            ex2.erase(pos);
            exo[vs[pos][0]] = exo[vs[pos][1]] = 1;
            posoi++;
        }
    }
    f(i,0,posoi){
        ans *= 2;
        ans %= INF;
    }
    cout<<ans<<" "<<ex.size()<<endl;
    for(auto x:ex){
        cout<<x<<" ";
    }
}

