#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 7, mod = 1e9 + 7;
long long idx[N], cnt[N];
;
vector<long long> v[N];
long long msb(vector<long long> a) { return a.back(); }
vector<long long> XOR(vector<long long> a, vector<long long> b) {
  a.pop_back();
  b.pop_back();
  if (a.empty()) return b;
  if (b.empty()) return a;
  a.push_back(b[0]);
  if (a[0] > a[1]) swap(a[0], a[1]);
  return a;
}
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, r = 1;
  cin >> n >> m;
  vector<long long> ans;
  for (long long i = 1; i <= n; i++) {
    long long l;
    cin >> l;
    v[i] = vector<long long>(l);
    for (long long &x : v[i]) cin >> x;
    while (v[i].size()) {
      long long k = msb(v[i]);
      if (!idx[k]) {
        r = (r + r) % mod;
        ans.push_back(i);
        idx[k] = i;
        break;
      }
      v[i] = XOR(v[i], v[idx[k]]);
    }
  }
  cout << r << " " << ans.size() << endl;
  for (long long x : ans) cout << x << " ";
}
