#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
using vec = std::vector<T>;
template <typename T>
using uset = std::unordered_set<T>;
template <typename T1, typename T2>
using umap = std::unordered_map<T1, T2>;
constexpr ll INFL = 1000000000000000069;
constexpr ll INFI = 1000000069;
const ld PI = acos(-1);
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
vec<pair<ll, ll>> DD = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
const ll N = 5e5 + 10;
ll pr[N], sz[N];
ll get(ll u) {
  if (pr[u] == -1) return u;
  return pr[u] = get(pr[u]);
}
bool unite(ll u, ll v) {
  u = get(u);
  v = get(v);
  if (u == v) return false;
  if (sz[u] < sz[v]) swap(u, v);
  pr[v] = u;
  sz[u] += sz[v];
  return true;
}
void run() {
  ll n, m;
  cin >> n >> m;
  fill(pr, pr + N, -1);
  fill(sz, sz + N, 1);
  vec<ll> usd(m);
  vec<tuple<ll, ll, ll>> a;
  vec<ll> ans;
  ll ansik = 1;
  const ll MOD = 1e9 + 7;
  set<ll> st;
  for (ll i = 0; i < n; i++) {
    ll k;
    cin >> k;
    if (k == 1) {
      ll x;
      cin >> x;
      x--;
      usd[x] = 1;
      ansik *= 2;
      ansik %= MOD;
      ans.push_back(i);
      st.insert(i);
    } else {
      ll x, y;
      cin >> x >> y;
      x--, y--;
      a.emplace_back(x, y, i);
    }
  }
  for (auto [x, y, i] : a) {
    if ((!usd[x] || !usd[y]) && unite(x, y)) {
      ansik *= 2;
      ansik %= MOD;
      st.insert(x);
      st.insert(y);
      ans.push_back(i);
    }
  }
  ansik = 1;
  for (ll i = 0; i < min(ans.size(), st.size()); i++) {
    ansik *= 2;
    ansik %= MOD;
  }
  cout << ansik << ' ' << ans.size() << '\n';
  sort(ans.begin(), ans.end());
  for (auto el : ans) {
    cout << el + 1 << ' ';
  }
  cout << '\n';
}
signed main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll t = 1;
  while (t--) {
    run();
  }
  return 0;
}
