#include <bits/stdc++.h>
using namespace std;
long long i, j, k, l, n, m, res;
long long par[500009], can[500009], sz[500009];
long long mpow(long long n, long long m) {
  long long res = 1, curr = n;
  while (m) {
    if (m & 1) res = (res * curr) % 1000000007;
    curr = (curr * curr) % 1000000007;
    m /= 2;
  }
  return res;
}
long long parent(long long x) {
  if (x == par[x]) return x;
  return par[x] = parent(par[x]);
}
void unionset(long long x, long long y) {
  x = parent(x);
  y = parent(y);
  if (x == y) return;
  if (rand() % 2 == 0) {
    can[x] |= can[y];
    par[y] = x;
  } else {
    can[y] |= can[x];
    par[x] = y;
  }
}
vector<long long> ans;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (i = 1; i <= m; i++) par[i] = i;
  par[m + 1] = m + 1;
  for (i = 1; i <= n; i++) {
    cin >> k;
    long long a, b;
    cin >> a;
    if (k > 1) cin >> b;
    if (k == 1) {
      if (can[parent(a)] == 0) ans.push_back(i);
      unionset(a, m + 1);
      can[parent(a)] = 1;
    } else {
      if (parent(a) != parent(b)) ans.push_back(i), unionset(a, b);
      if (parent(a) != parent(m + 1)) unionset(a, m + 1);
    }
  }
  cout << mpow(2, ans.size()) << ' ' << ans.size() << '\n';
  for (auto to : ans) cout << to << ' ';
  cout << '\n';
  exit(0);
}
