#include <bits/stdc++.h>
using namespace std;
struct DSU {
  vector<long long> P, sz;
  long long cnt;
  DSU(long long N) {
    cnt = N;
    P.resize(N), sz.resize(N, 1);
    for (long long x = 0; x < N; x++) P[x] = x;
  }
  long long fp(long long x) { return (P[x] == x) ? x : P[x] = fp(P[x]); }
  void mu(long long x, long long y) {
    x = fp(x), y = fp(y);
    if (x == y) return;
    cnt--;
    P[x] = y;
    sz[y] += sz[x];
    return;
  }
};
unsigned long long binexp(unsigned long long base, unsigned long long pow,
                          unsigned long long M = 0) {
  unsigned long long res = 1;
  while (pow) {
    if (pow & 1) res *= base;
    pow >>= 1, base *= base;
    if (M) base %= M, res %= M;
  }
  return res;
}
vector<vector<pair<long long, long long> > > adj(5e5 + 5);
vector<long long> loner(5e5 + 5), is_loner(5e5 + 5);
void dfs(long long u, long long p) {
  for (auto [v, g] : adj[u]) {
    if (v == p) continue;
    if (loner[v] == 1) continue;
    loner[v] = 1;
    is_loner[g] = 1;
    dfs(v, u);
  }
  return;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, long long> > poop(n);
  for (long long x = 0; x < n; x++) {
    long long k;
    cin >> k;
    if (k == 1) {
      long long i;
      cin >> i;
      loner[i - 1] = 1;
      is_loner[x] = 1;
    } else {
      long long u, v;
      cin >> u >> v;
      u--, v--;
      adj[u].push_back({v, x});
      adj[v].push_back({u, x});
      poop[x] = {u, v};
    }
  }
  for (long long x = 0; x < m; x++) {
    if (loner[x] == 1) dfs(x, x);
  }
  DSU uf(m);
  vector<long long> rest;
  for (long long x = 0; x < n; x++) {
    if (is_loner[x]) continue;
    long long u = poop[x].first;
    long long v = poop[x].second;
    if (loner[u] || loner[v]) continue;
    if (uf.fp(u) == uf.fp(v)) continue;
    uf.mu(u, v);
    rest.push_back(x);
  }
  long long ans =
      binexp(2, accumulate(loner.begin(), loner.end(), 0ll), 1000000007);
  for (long long x = 0; x < m; x++) {
    if (loner[x]) continue;
    if (uf.fp(x) != x) continue;
    ans *= binexp(2, uf.sz[x] - 1, 1000000007);
    ans %= 1000000007;
  }
  for (long long x = 0; x < n; x++) {
    if (is_loner[x]) rest.push_back(x);
  }
  sort(rest.begin(), rest.end());
  cout << ans << " " << rest.size() << endl;
  for (auto i : rest) cout << i + 1 << " ";
  cout << endl;
  return 0;
}
