#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(nullptr));
const long long INF = 1e18, P = 1e9 + 7, N = 5e5 + 10;
const long double EPS = 1e-9;
long long pr[N], rk[N];
long long get_root(long long x) {
  return (x == pr[x] ? x : pr[x] = get_root(pr[x]));
}
void mrg(long long y1, long long y2) {
  if (rk[y1] > rk[y2]) {
    swap(y1, y2);
  }
  pr[y1] = y2;
  if (rk[y1] == rk[y2]) {
    rk[y2]++;
  }
}
bool add(long long v, long long u) {
  v = get_root(v);
  u = get_root(u);
  if (v == u) {
    return false;
  }
  mrg(v, u);
  return true;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  map<pair<long long, long long>, long long> mp;
  vector<long long> used(m), ans;
  vector<pair<long long, long long> > ed;
  for (long long i = 0; i < n; i++) {
    long long k;
    cin >> k;
    if (k == 1) {
      long long x;
      cin >> x;
      x--;
      ans.push_back(i + 1);
      used[x] = 1;
    } else {
      long long v, u;
      cin >> v >> u;
      v--;
      u--;
      mp[{v, u}] = i;
      ed.push_back({v, u});
    }
  }
  for (long long i = 0; i < m; i++) {
    pr[i] = i;
    rk[i] = 1;
  }
  for (pair<long long, long long> p : ed) {
    long long v = p.first, u = p.second;
    if (!(used[v] && used[u]) && add(v, u)) {
      ans.push_back(mp[{v, u}] + 1);
    }
  }
  sort(ans.begin(), ans.end());
  long long pw = 1, cnt = ans.size();
  for (long long i = 0; i < ans.size(); i++) {
    pw *= 2;
    pw %= P;
  }
  cout << pw << ' ' << ans.size() << "\n";
  for (long long elem : ans) {
    cout << elem << ' ';
  }
  cout << "\n";
  return 0;
}
