#include <bits/stdc++.h>
using namespace std;
long long unsigned n, m, k, ss, ans, uset[(500000 + 50)], x, x1, x2,
    si[(500000 + 50)];
bool h[(500000 + 50)];
vector<long long unsigned> v;
inline long long unsigned fnd(long long unsigned x) {
  while (x != uset[x]) x = uset[x] = uset[uset[x]];
  return x;
}
inline long long unsigned ksm(long long unsigned x) {
  long long unsigned ret = 1;
  for (long long unsigned b = 2; x && ret; x >>= 1, b = (b << 1) % 1000000007)
    if (x & 1) ret = (ret * b) % 1000000007;
  return ret;
}
signed main() {
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  cin >> n >> m;
  for (long long unsigned i = 1; i <= m; ++i) {
    uset[i] = i;
  }
  for (long long unsigned i = 1; i <= n; ++i) {
    cin >> k;
    if (k == 1) {
      cin >> x;
      if (!h[x]) {
        h[x] = 1;
        ++si[x];
        v.push_back(i);
      }
    } else {
      cin >> x1 >> x2;
      if (!h[x1] && !h[x2] && fnd(x1) != fnd(x2)) {
        uset[fnd(x1)] = fnd(x2);
        v.push_back(i);
      } else if (!h[x1] && !h[x2] && !h[fnd(x1)]) {
        h[fnd(x1)] = 1;
        v.push_back(i);
      }
    }
  }
  ans = 1;
  for (long long unsigned i = 1; i <= m; ++i)
    if (fnd(i) != i) ++si[fnd(i)];
  for (long long unsigned i = 1; i <= m; ++i)
    if (uset[i] == i) ans = (ans * ksm(si[i])) % 1000000007;
  cout << ans << ' ' << v.size() << '\n';
  for (vector<long long unsigned>::const_iterator it = v.begin(); it != v.end();
       ++it)
    cout << *it << ' ';
  return 0;
}
