/*
	Author: AquaBlaze
	Time: 2020-12-30 23:16:53
	Generated by powerful Codeforces Tool
 	You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)	
    Keqing best girl :)
    Nephren will always be in my heart
*/
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define ROF(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())
#define pc(x) putchar(x)
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long i64;
typedef tuple<int,int,int> iii;
typedef pair<int,int> pii;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int N = 500005;

vi ans;
vi Stack;
int dsu[N];

int find(int i){
    if(i == dsu[i]) return i;
    Stack.eb(i);
    while(dsu[Stack.back()] != Stack.back()){
        Stack.eb(dsu[Stack.back()]);
    }
    int p = Stack.back();
    Stack.pop_back();
    while(!Stack.empty()){
        dsu[Stack.back()] = p;
        Stack.pop_back();
    }
    return dsu[i];
}

bool occupied[N];
const int inf = (1<<29);
const int mod = 1000000007;

void solve(){
    ans.clear();
    int n, m;
    cin >> n >> m;
    FOR(i, 1, m) dsu[i] = i;
    FOR(i, 1, n){
        int k, a, b;
        cin >> k >> a;
        if(occupied[a]){
            a = find(a);
        }
        if(k == 1){
            if(occupied[a]) continue;
            occupied[a] = true;
            ans.eb(i);
        }else{
            cin >> b;
            if(occupied[b]) b = find(b);
            if(occupied[b]) b = inf;
            if(occupied[a]) a = inf;
            if(a > b) swap(a,b);
            if(a == inf) continue;
            if(a == b) continue;
            occupied[a] = true;
            if(b != inf) dsu[a] = b;
            ans.eb(i);
        }
    }
    int cnt = 1;
    FOR(i, 1, SZ(ans)) cnt = (cnt+cnt)%mod;
    printf("%d %d\n",cnt,SZ(ans));
    for(const int &e : ans) printf("%d ",e);
    puts("");
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */
