#include <bits/stdc++.h>
using namespace std;
const int tam = 500010;
const int MOD = 1000000007;
const int MOD1 = 998244353;
const double EPS = 1e-9;
const double PI = acos(-1);
pair<pair<int, int>, int> ar[tam];
bool uns[tam];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int a, b, c;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (a == 1) {
      ar[i] = {{b - 1, -1}, i};
    } else {
      cin >> c;
      if (b > c) swap(b, c);
      ar[i] = {{b - 1, c - 1}, i};
    }
  }
  vector<int> res;
  set<pair<int, int>> st;
  for (int i = 0; i < n; i++) {
    if (st.count(ar[i].first) == 0) {
      if (ar[i].first.second == -1) {
        if (!uns[ar[i].first.first]) {
          uns[ar[i].first.first] = 1;
          st.insert(ar[i].first);
          res.push_back(ar[i].second);
        }
      } else {
        if (!uns[ar[i].first.first] || !uns[ar[i].first.second]) {
          if (uns[ar[i].first.first])
            uns[ar[i].first.second] = 1;
          else if (uns[ar[i].first.second])
            uns[ar[i].first.first] = 1;
          res.push_back(ar[i].second);
          st.insert(ar[i].first);
        }
      }
    }
  }
  long long po = 1;
  for (int i = 0; i < res.size(); i++) po = po * 2 % MOD;
  cout << po << ' ' << res.size() << '\n';
  sort((res).begin(), (res).end());
  for (int i = 0; i < res.size(); i++) {
    if (i > 0) cout << ' ';
    cout << res[i] + 1;
  }
  cout << '\n';
  return 0;
}
