#include <bits/stdc++.h>
using namespace std;
const int MAX = 5e5 + 3;
const long long MOD = 1e9 + 7;
int par[MAX], isParent[MAX];
long long sz[MAX];
int id[MAX];
vector<int> ans;
int Find(int u) {
  if (par[u] == u) return u;
  return par[u] = Find(par[u]);
}
void Union(int u, int v, int idx) {
  u = Find(u);
  v = Find(v);
  if (u != v) {
    if (sz[u] < sz[v]) swap(u, v);
    par[v] = u;
    sz[u] += sz[v];
    ans.push_back(idx);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  m++;
  for (int i = 1; i <= m; i++) par[i] = i, sz[i] = 1;
  for (int i = 1; i <= n; i++) {
    int k;
    cin >> k;
    if (k == 1) {
      int x;
      cin >> x;
      Union(x, m, i);
    } else {
      int u, v;
      cin >> u >> v;
      Union(u, v, i);
    }
  }
  for (int i = 1; i <= m; i++) {
    isParent[Find(i)] = 1;
  }
  long long res = 1LL;
  for (int i = 1; i <= m; i++) {
    if (isParent[i]) {
      res *= (1LL << (sz[i] - 1)) % MOD;
      res %= MOD;
    }
  }
  sort(ans.begin(), ans.end());
  cout << res << " " << ans.size() << "\n";
  for (int x : ans) cout << x << " ";
}
