#include <bits/stdc++.h>
using namespace std;
const long long int M = 1e9 + 7, N = 5e5;
;
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
class DSU {
 public:
  vector<long long int> A, B;
  DSU(long long int n) {
    A.resize(n);
    B.resize(n);
    for (long long int i = 0; i < n; i++) {
      A[i] = i;
      B[i] = 1;
    }
  }
  long long int find(long long int a) {
    if (a == A[a]) return a;
    return A[a] = find(A[a]);
  }
  void unite(long long int a, long long int b) {
    long long int temp1 = find(a);
    long long int temp2 = find(b);
    if (B[a] < B[b]) swap(a, b);
    A[b] = a;
    B[a] += B[b];
  }
};
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m, a, b, k;
  cin >> n >> m;
  vector<pair<long long int, pair<long long int, long long int> > > V;
  vector<long long int> U;
  DSU d(m + 1);
  for (long long int i = 0; i < n; i++) {
    cin >> k;
    if (k == 1) {
      cin >> a;
      a--;
      V.push_back({i, {a, m}});
    } else {
      cin >> a >> b;
      a--, b--;
      if (a > b) swap(a, b);
      V.push_back({i, {a, b}});
    }
  }
  sort(V.begin(), V.end());
  for (auto x : V) {
    if (d.find(x.second.first) != d.find(x.second.second)) {
      d.unite(x.second.first, x.second.second);
      U.push_back(x.first);
    }
  }
  cout << power(2, U.size(), M) << " " << U.size() << "\n";
  for (auto x : U) cout << x + 1 << " ";
  cout << "\n";
  return 0;
}
