#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:67108864")
using namespace std;
const double EPS = 1E-12;
const double PI = acos(-1.0);
const long long mod = 1000000007;
using namespace std;
int n, m, x, y, k;
long long modpow(int p) {
  if (p == 0) return 1;
  long long rv = modpow(p / 2);
  if (p & 1) {
    return (rv * rv * 2) % mod;
  } else {
    return (rv * rv) % mod;
  }
}
void solve() {
  vector<int> a;
  vector<unordered_set<int> > e;
  vector<bool> ind;
  int cluster;
  cin >> n >> m;
  a.assign(m, -1);
  e.assign(m, unordered_set<int>());
  ind.assign(m, false);
  cluster = 0;
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    cin >> k;
    if (k == 1) {
      cin >> x;
      x--;
      if (a[x] == -1) {
        a[x] = cluster;
        e[cluster].insert(x);
        ind[cluster] = true;
        cluster++;
        ans.push_back(i);
      } else if (!ind[a[x]]) {
        ind[a[x]] = true;
        ans.push_back(i);
      }
    } else {
      cin >> x >> y;
      x--;
      y--;
      if (a[x] == -1 && a[y] == -1) {
        a[x] = cluster;
        a[y] = cluster;
        e[cluster].insert(x);
        e[cluster].insert(y);
        cluster++;
        ans.push_back(i);
      } else if (a[x] == -1) {
        a[x] = a[y];
        e[a[y]].insert(x);
        ans.push_back(i);
      } else if (a[y] == -1) {
        a[y] = a[x];
        e[a[x]].insert(y);
        ans.push_back(i);
      } else if (a[x] != a[y] && (!ind[a[x]] || !ind[a[y]])) {
        if (e[a[x]].size() > e[a[y]].size()) {
          swap(x, y);
        }
        ind[a[y]] = ind[a[y]] | ind[a[x]];
        for (auto elem : e[a[x]]) {
          a[elem] = a[y];
        }
        e[a[y]].insert(e[a[x]].begin(), e[a[x]].end());
        ans.push_back(i);
      }
    }
  }
  long long rv = 1;
  for (int i = 0; i < ans.size(); i++) {
    rv *= 2;
    rv %= mod;
  }
  cout << rv << ' ' << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] + 1 << ' ';
  cout << endl;
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  solve();
  return 0;
}
