#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAX = 500005;
int add(int x, int y) {
  x += y;
  while (x >= MOD) {
    x -= MOD;
  }
  while (x < 0) {
    x += MOD;
  }
  return x;
}
int mul(int x, int y) { return (x * 1ll * y) % MOD; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, a, b, c;
  cin >> n >> m;
  vector<pair<pair<int, int>, int>> v2;
  vector<int> sol;
  vector<int> cnt1(MAX);
  vector<int> cnt2(MAX);
  for (int i = 1; i <= n; i++) {
    cin >> a;
    if (a == 1) {
      cin >> b;
      if (cnt1[b]) {
        continue;
      }
      sol.push_back(i);
      cnt1[b] = 1;
    } else {
      cin >> b >> c;
      v2.push_back({{b, c}, i});
    }
  }
  sort(v2.begin(), v2.end());
  for (int i = 0; i < v2.size(); i++) {
    b = v2[i].first.first;
    c = v2[i].first.second;
    if (cnt1[b] && cnt1[c]) {
      v2[i].second = 0;
    } else {
      cnt2[b]++;
      cnt2[c]++;
    }
  }
  for (int i = 0; i < v2.size(); i++) {
    b = v2[i].first.first;
    c = v2[i].first.second;
    if (v2[i].second == 0) {
      continue;
    }
    if (cnt2[b] > 1 && cnt2[c] > 1) {
      v2[i].second = 0;
      cnt2[b]--;
      cnt2[c]--;
    }
  }
  for (int i = 0; i < v2.size(); i++) {
    if (v2[i].second > 0) {
      sol.push_back(v2[i].second);
    }
  }
  sort(sol.begin(), sol.end());
  int total = 1;
  for (int i = 0; i < sol.size(); i++) {
    total = add(total, total);
  }
  cout << total << " " << sol.size() << endl;
  for (auto e : sol) {
    cout << e << " ";
  }
  cout << endl;
}
