#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream &operator<<(ostream &cout, pair<A, B> const &p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
const long long MOD = 1e9 + 7;
long long t, n, m, one[500005], sz[500005], par[500005], p2[500005], k, t1, t2,
    two[500005], cmp[500005];
pair<long long, long long> a[500005];
long long fnd(long long g) {
  if (g == par[g]) return g;
  return par[g] = fnd(par[g]);
}
void uni(long long x, long long y) {
  x = fnd(x);
  y = fnd(y);
  if (x == y) return;
  if (sz[x] < sz[y]) swap(x, y);
  par[y] = x;
  sz[x] += sz[y];
  one[x] += one[y];
}
void solve() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    sz[i] = 1;
    par[i] = i;
  }
  for (int i = 1; i <= n; i++) {
    cin >> k;
    if (k == 2) {
      cin >> t1 >> t2;
      two[t1] = 1;
      two[t2] = 1;
      uni(t1, t2);
      a[i] = make_pair(t1, t2);
    } else {
      cin >> t1;
      one[fnd(t1)] = 1;
      a[i] = make_pair(t1, 0);
    }
  }
  long long cur = 1;
  for (int i = 1; i <= m; i++) {
    if (!two[i] && !one[i]) continue;
    if (cmp[fnd(i)]) continue;
    cmp[fnd(i)] = 1;
    if (one[fnd(i)])
      cur *= p2[sz[fnd(i)]];
    else
      cur *= p2[sz[fnd(i)] - 1];
    cur %= MOD;
  }
  vector<long long> ans;
  for (int i = 1; i <= n; i++) {
    if (a[i].first && a[i].second) {
      if (one[a[i].first] && one[a[i].second]) continue;
    }
    ans.push_back(i);
  }
  cout << cur << ' ';
  cout << ans.size() << '\n';
  for (auto u : ans) cout << u << " ";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  p2[0] = 1;
  for (int i = 1; i <= 500000; i++) {
    p2[i] = p2[i - 1];
    p2[i] <<= 1LL;
    p2[i] %= MOD;
  }
  t = 1;
  for (int i = 1; i <= t; i++) solve();
  cout.flush();
  return 0;
}
