#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
const int MAX = 5e5 + 2;
const int MOD = 1e9 + 7;
vector<int> comp(MAX);
int find(int x) { return (comp[x] == x ? x : comp[x] = x); }
bool uni(int x, int y) {
  x = find(x), y = find(y);
  comp[x] = y;
  return (x != y);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) comp[i] = i;
  vector<int> second;
  for (int i = 0; i < n; i++) {
    int k, d1, d2;
    cin >> k >> d1;
    if (k > 1)
      cin >> d2;
    else
      d2 = m + 1;
    if (uni(d1, d2)) second.push_back(i + 1);
  }
  long long ans = 1;
  for (int i = 0; i < second.size(); i++) {
    ans *= 2;
    ans %= MOD;
  }
  cout << ans << " " << second.size() << '\n';
  for (int i : second) cout << i << " ";
  cout << '\n';
  exit(0);
}
