#include <bits/stdc++.h>
using namespace std;
const int MAXM = 5e5 + 10;
const long long MOD = 1e9 + 7;
int n, m;
bool ones[MAXM], needed[MAXM];
vector<pair<int, int> > inp;
vector<int> vals[MAXM];
int main(void) {
  ios_base::sync_with_stdio(0);
  memset(ones, 0, sizeof(ones));
  memset(needed, 0, sizeof(needed));
  cin >> n >> m;
  int k, u, v;
  for (int i = 0; i < n; i++) {
    cin >> k;
    if (k == 1) {
      cin >> u;
      inp.push_back(pair<int, int>(u - 1, -1));
    } else {
      cin >> u >> v;
      inp.push_back(pair<int, int>(min(u - 1, v - 1), max(u - 1, v - 1)));
    }
  }
  for (int i = 0; i < n; i++) {
    if (inp[i].second == -1 && !ones[inp[i].first]) {
      needed[i] = 1;
      ones[inp[i].first] = 1;
      deque<int> to_add;
      to_add.push_back(inp[i].first);
      while (to_add.size() > 0) {
        int ex = to_add.front();
        to_add.pop_front();
        for (int j = 0; j < vals[ex].size(); j++) {
          int idx = vals[ex][j];
          if (!ones[inp[idx].first]) {
            ones[inp[idx].first] = 1;
            to_add.push_back(inp[idx].first);
          }
          if (!ones[inp[idx].second]) {
            ones[inp[idx].second] = 1;
            to_add.push_back(inp[idx].second);
          }
        }
      }
    } else if (inp[i].second != -1 && !ones[inp[i].first] &&
               !ones[inp[i].second]) {
      needed[i] = 1;
      vals[inp[i].first].push_back(i);
      vals[inp[i].second].push_back(i);
    }
  }
  long long tot = 1, ex = 0;
  for (int i = 0; i < n; i++) {
    if (needed[i]) {
      tot *= 2;
      tot %= MOD;
      ex++;
    }
  }
  cout << tot << " " << ex << "\n";
  for (int i = 0; i < n; i++) {
    if (needed[i]) cout << (i + 1) << " ";
  }
  cout << "\n";
  return 0;
}
