#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
long long int mpow(long long int x, long long int y) {
  long long int res = 1;
  x = x % mod;
  while (y > 0) {
    if (y & 1) res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res;
}
bool comp(pair<long long int, pair<long long int, long long int>> a,
          pair<long long int, pair<long long int, long long int>> b) {
  if (a.second.first == -1 && b.second.first != -1) return true;
  if (a.second.first != -1 && b.second.first == -1) return false;
  return a < b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int T = clock();
  long long int n, m;
  cin >> n >> m;
  vector<pair<long long int, pair<long long int, long long int>>> a;
  set<pair<long long int, long long int>> s;
  map<long long int, long long int> idn;
  for (long long int i = 0; i < n; i++) {
    long long int k, x, y;
    cin >> k;
    if (k == 1) {
      x = -1;
      cin >> y;
      if (s.find({-1, y}) == s.end()) idn[y] = i;
    } else {
      cin >> x >> y;
      if (x > y) swap(x, y);
    }
    if (s.find({x, y}) == s.end()) a.push_back({i, {x, y}});
    s.insert({x, y});
  }
  n = a.size();
  sort(a.begin(), a.end(), comp);
  vector<long long int> b(m + 1);
  set<long long int> ans;
  for (long long int i = 0; i < n; i++) {
    long long int id = a[i].first, x = a[i].second.first,
                  y = a[i].second.second;
    if (x == -1) {
      if (b[y] != 1) {
        ans.insert(id);
        b[y] = 1;
      }
    } else {
      if (b[x] != 1 || b[y] != 1) {
        ans.insert(id);
        b[x] = b[y] = 1;
      } else if (idn[x] == 0 && idn[y] == 0) {
        ans.insert(id);
      } else {
        long long int p = idn[x], q = idn[y];
        ans.erase(p);
        ans.erase(q);
        vector<long long int> c = {p, q, id};
        sort(c.begin(), c.end());
        ans.insert(c[0]);
        ans.insert(c[1]);
      }
    }
  }
  long long int len = ans.size();
  long long int k = mpow(2, len);
  cout << k << " " << len << "\n";
  for (long long int val : ans) cout << val + 1 << " ";
  cerr << "\n\nTIME: " << (double)(clock() - T) / CLOCKS_PER_SEC << " sec\n";
  T = clock();
  return 0;
}
