#include <bits/stdc++.h>
using namespace std;
const long long N = 5e3 + 10;
long long p = 1e9 + 7;
struct DSU {
  long long n;
  vector<long long> f;
  DSU(long long n) : n(n), f(n + 1) {
    for (long long i = 1; i <= n; i++) f[i] = i;
  }
  long long fd(long long x) { return f[x] = f[x] == x ? x : fd(f[x]); }
  bool merge(long long x, long long y) {
    long long fx = fd(x), fy = fd(y);
    if (fx != fy) f[fy] = fx;
    return fx != fy;
  }
};
signed main() {
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  DSU d(m + 1);
  vector<long long> v;
  for (long long i = 1; i <= n; i++) {
    long long k;
    cin >> k;
    if (k == 1) {
      long long x;
      cin >> x;
      d.merge(x, m + 1);
      v.push_back(i);
    } else {
      long long x, y;
      cin >> x >> y;
      if (d.merge(x, y)) v.push_back(i);
    }
  }
  long long ans = 1;
  for (long long i = 0; i < v.size(); i++) ans = ans * 2 % p;
  cout << ans << ' ' << v.size() << '\n';
  for (long long i = 0; i < v.size(); i++)
    cout << v[i] << " \n"[i == v.size() - 1];
  return 0;
}
