#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define lll __int128
#define ull unsigned long long
#define fi first
#define se second
#define db double
#define ld long double
#define lld __float128

/// order_of_key, find_by_order

template<class T, class COMP>
using custom_set = tree<T, null_type, COMP, rb_tree_tag, tree_order_statistics_node_update>;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class T, class U>
using ordered_map = tree<T, U, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd_64(chrono::steady_clock::now().time_since_epoch().count());

const ll MOD = 1e9 + 7;

int lead[500005][21];
pair<int, int> dat[500005];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n, m; cin >> n >> m;
    for(int i = 0; i <= m; i++)
    {
        for(int j = 0; j < 21; j++)
        {
            lead[i][j] = -1;
        }
    }

    for(int i = 0; i < n; i++)
    {
        int k; cin >> k;
        if(k == 1)
        {
            cin >> dat[i].fi; dat[i].se = m; dat[i].fi--;
        }
        else
        {
            cin >> dat[i].fi >> dat[i].se;
            dat[i].fi--; dat[i].se--;
            if(dat[i].fi > dat[i].se)
                swap(dat[i].fi, dat[i].se);
        }
    }
    vector<int> ans;
    for(int i = 0; i < n; i++)
    {
        pair<int, int> x = dat[i];
        bool b = 0;
        for(int j = 20; j >= 0; j--)
        {
            if(lead[x.fi][j] != -1)
            {
                x.fi = lead[x.fi][j];
            }
        }
        for(int j = 20; j >= 0; j--)
        {
            if(lead[x.se][j] != -1)
            {
                x.se = lead[x.se][j];
            }
        }
        if(x.fi != x.se)
        {
            if(x.fi > x.se)
            {
                swap(x.fi, x.se);
                swap(dat[i].fi, dat[i].se);
            }
            if(x.fi != m)
            {
                x.se = dat[i].se;
                for(int j = 20; j >= 0; j--)
                {
                    if(lead[x.se][j] != -1 && lead[x.se][j] < x.fi)
                    {
                        x.se = lead[x.se][j];
                    }
                }
                if(x.se < x.fi)
                    x.se = lead[x.se][0];
                lead[x.fi][0] = x.se;
                for(int j = 1; j <= 20; j++)
                {
                    if(lead[x.fi][j-1] == -1)
                        lead[x.fi][j] = -1;
                    else
                        lead[x.fi][j] = lead[lead[x.fi][j-1]][j-1];
                }
                b = 1;
            }

        }
        if(b)
            ans.push_back(i+1);
    }
    ll res = 1;
    for(int i = 0; i < ans.size(); i++)
    {
        res = (res * 2ll) % MOD;
    }
    cout << res << ' ' << ans.size() << '\n';
    for(int i = 0; i < ans.size(); i++)
        cout << ans[i] << ' ';
}






































/// shche ne vmerla Ykraina
