#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
const int mm = 1e9 + 7;
int f[maxn], vis[maxn];
int Find(int x) { return x == f[x] ? x : f[x] = Find(f[x]); }
void Union(int x, int y) {
  x = Find(x), y = Find(y);
  vis[x] |= vis[y];
  f[y] = x;
}
vector<int> ans;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) f[i] = i;
  for (int i = 1, u, v; i <= n; ++i) {
    int k;
    cin >> k;
    if (k == 2) {
      cin >> u >> v;
      if (Find(u) != Find(v)) {
        if (!vis[Find(u)] || !vis[Find(v)]) {
          ans.push_back(i);
        }
        Union(u, v);
      }
    } else {
      cin >> u;
      if (!vis[Find(u)]) {
        vis[Find(u)] = 1;
        ans.push_back(i);
      }
    }
  }
  long long fin = 1;
  for (auto &v : ans) {
    fin = fin * 2 % mm;
  }
  cout << fin << ' ' << ans.size() << endl;
  for (auto &v : ans) {
    cout << v << ' ';
  }
  cout << endl;
  return 0;
}
