#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
const int MOD = 1e9 + 7;
int cnt[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int cur = m;
  vector<int> v;
  for (int i = 1; i <= n; ++i) {
    int k;
    cin >> k;
    if (k == 1) {
      int x;
      cin >> x;
      if (cur == m - 1 && cnt[x] % 2 == 1) continue;
      cnt[x] = (cnt[x] + 1) % 2;
      if (cnt[x] == 0)
        ++cur;
      else
        --cur;
      v.push_back(i);
    } else {
      int x, y;
      cin >> x >> y;
      if (cur == m - 2 && cnt[x] % 2 == 1 && cnt[y] % 2 == 1) continue;
      cnt[x] = (cnt[x] + 1) % 2;
      cnt[y] = (cnt[y] + 1) % 2;
      if (cnt[x] == 0)
        ++cur;
      else
        --cur;
      if (cnt[y] == 0)
        ++cur;
      else
        --cur;
      v.push_back(i);
    }
  }
  int t = 1;
  for (int i = 1; i <= v.size(); ++i) {
    t = t * 2 % MOD;
  }
  cout << t << ' ' << v.size() << endl;
  for (int i = 0; i < v.size(); ++i) {
    cout << v[i];
    if (i < v.size() - 1) cout << ' ';
  }
  cout << endl;
  return 0;
}
