#include <bits/stdc++.h>
using namespace std;
int getRoot(int N, map<int, int> &parent) {
  if (parent.find(N) == parent.end()) {
    parent[N] = N;
    return parent[N];
  }
  if (parent[N] != N) {
    parent[N] = getRoot(parent[N], parent);
  }
  return parent[N];
}
long long MOD = 1e9 + 7;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> res;
  set<int> one;
  map<int, int> parent;
  map<int, vector<int> > musiqueDascenseur;
  for (int c = 0; c < N; c++) {
    int k;
    cin >> k;
    if (k == 2) {
      int a, b;
      cin >> a >> b;
      if (one.find(a) != one.end() && one.find(b) != one.end()) continue;
      if (one.find(a) != one.end()) one.insert(b);
      if (one.find(b) != one.end()) one.insert(a);
      int r1 = getRoot(a, parent);
      int r2 = getRoot(b, parent);
      if (r1 == r2) continue;
      parent[r1] = r2;
      res.push_back(c);
      musiqueDascenseur[a].push_back(b);
      musiqueDascenseur[b].push_back(a);
    } else {
      int a;
      cin >> a;
      if (one.find(a) == one.end()) {
        one.insert(a);
        res.push_back(c);
        for (auto z : musiqueDascenseur[a]) one.insert(z);
        musiqueDascenseur[a].clear();
      }
    }
  }
  long long r = 1;
  for (int c = 0; c < one.size(); c++) {
    r *= 2LL;
    r %= MOD;
  }
  map<int, long long unsigned int> tailles;
  for (auto z : parent) {
    tailles[getRoot(z.first, parent)]++;
  }
  for (auto z : tailles) {
    r *= (1ULL + (((z.second) * (z.second - 1ULL)) / 2ULL)) % MOD;
    r %= MOD;
  }
  cout << r << " " << res.size() << endl;
  for (auto z : res) cout << z + 1 << " ";
}
