#include <bits/stdc++.h>
using namespace std;
const long long N = 500005;
const long double PI = 3.1415926535;
const long double eps = 1e-07;
const long long INF = 1e18;
const long long inf = 1e9;
const long long M = 1e9 + 7;
const string IO[2]{"NO\n", "YES\n"};
const string io[2]{"No\n", "Yes\n"};
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
void vcin(vector<long long>& x) {
  for (long long& element : x) {
    cin >> element;
  }
}
void vcout(vector<long long>& x) {
  for (long long& element : x) {
    cout << element;
  }
}
long long sz[N], p[N];
bool vv[N];
long long get(long long x) {
  if (x == p[x]) return x;
  return p[x] = get(p[x]);
}
void join(long long x, long long y) {
  x = get(x);
  y = get(y);
  if (sz[x] > sz[y]) swap(x, y);
  sz[y] += sz[x];
  p[x] = y;
  vv[y] |= vv[x];
}
void solve() {
  for (long long i = 0; i < N; ++i) {
    sz[i] = 1;
    p[i] = i;
    vv[i] = false;
  }
  long long n, m;
  cin >> n >> m;
  vector<long long> ans;
  for (long long i = 0; i < n; ++i) {
    long long k;
    cin >> k;
    if (k == 1) {
      long long x;
      cin >> x;
      --x;
      if (!vv[get(x)]) {
        vv[get(x)] = 1;
        ans.push_back(i + 1);
      }
    } else {
      long long x, y;
      cin >> x >> y;
      --x, --y;
      if (get(x) != get(y)) {
        join(x, y);
        ans.push_back(i + 1);
      }
    }
  }
  long long num = 1;
  for (long long i = 0; i < ans.size(); ++i) {
    num *= 2;
    num %= M;
  }
  cout << num << ' ' << ans.size() << '\n';
  sort(ans.begin(), ans.end());
  for (auto aa : ans) cout << aa << ' ';
  cout << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long t = 1;
  while (t--) solve();
}
