#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 5e5 + 42;
const long long mod = 1e9 + 7;
int am[N], can[N];
vector<pair<int, int> > cc[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n = 0, m = 0;
  cin >> n >> m;
  vector<pair<int, pair<int, int> > > s(n);
  vector<bool> u(n);
  for (int i = 0; i < n; i++) u[i] = true;
  queue<int> qq;
  for (auto& x : s) {
    cin >> x.first;
    if (x.first == 1)
      cin >> x.second.first;
    else
      cin >> x.second.first >> x.second.second;
  }
  for (int i = 0; i < n; i++)
    if (s[i].first == 2) {
      cc[s[i].second.first].push_back(make_pair(s[i].second.second, i));
      cc[s[i].second.second].push_back(make_pair(s[i].second.first, i));
    } else {
      u[i] = true;
      can[s[i].second.first] = true;
      qq.push(s[i].second.first);
    }
  vector<int> us;
  long long ans = 1;
  while (!qq.empty()) {
    auto cv = qq.front();
    qq.pop();
    for (auto& x : cc[cv])
      if (!can[x.first]) {
        u[x.second] = true;
        qq.push(x.first);
        can[x.first] = true;
      }
  }
  for (int i = 1; i <= m; i++)
    if (can[i]) ans = (ans * 2ll) % mod;
  for (int i = 0; i < n; i++)
    if (s[i].first == 2 && !can[s[i].second.first] &&
        !can[s[i].second.second]) {
      ans = (ans * 2ll) % mod;
      u[i] = true;
    }
  for (int i = 0; i < n; i++)
    if (u[i] = true) us.push_back(i + 1);
  cout << ans << ' ' << us.size() << endl;
  for (auto& x : us) cout << x << ' ';
  return 0;
}
