#include <bits/stdc++.h>
using namespace std;
long long p = 1e9 + 7LL;
long long exp(long long a, long long e) {
  long long r = 1;
  while (e) {
    if (e & 1) r = (r * a) % p;
    a = (a * a) % p;
    e >>= 1;
  }
  return r;
}
void solve() {
  int n, m;
  cin >> n >> m;
  map<int, int> M;
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    int k;
    cin >> k;
    if (k == 1) {
      int a;
      cin >> a;
      if (!M[a]) {
        ans.push_back(i);
        M[a] = 1;
      }
    } else {
      int a, b;
      cin >> a >> b;
      if (!M[a] || !M[b]) {
        ans.push_back(i);
        M[a] = 1, M[b] = 1;
      }
    }
  }
  int sz = (int)ans.size();
  cout << exp(2, sz) << ' ' << sz << '\n';
  for (int e : ans) cout << e << ' ';
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
