#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1000000007;
const int MX = 500000;
static int p[MX];
static int sz[MX];
static bool us[MX];
int find(int a) {
  if (p[a] == a) return a;
  return p[a] = find(p[a]);
}
bool uni(int a, int b) {
  a = find(a);
  b = find(b);
  if (a != b && !(us[a] && us[b])) {
    if (sz[a] > sz[b]) {
      swap(a, b);
    }
    p[a] = b;
    sz[b] += sz[a];
    us[b] |= us[a];
    return true;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    p[i] = i;
    sz[i] = 1;
    us[i] = false;
  }
  vector<vector<int>> ar(m);
  vector<tuple<int, int, int>> edge;
  static int pw[MX + 1];
  pw[0] = 1;
  for (int i = 1; i <= MX; ++i) {
    pw[i] = pw[i - 1] * 2;
    pw[i] %= MOD;
  }
  vector<int> who;
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    if (k == 1) {
      who.push_back(i + 1);
      int a;
      cin >> a;
      a--;
      us[a] = true;
    } else {
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      ar[a].push_back(b);
      ar[b].push_back(a);
      edge.emplace_back(a, b, i + 1);
    }
  }
  for (auto& [a, b, idx] : edge) {
    if (uni(a, b)) {
      who.push_back(idx);
    }
  }
  ll ans = 1;
  for (int i = 0; i < m; ++i) {
    if (p[i] == i) {
      ans *= pw[sz[i] - 1 + us[i]];
      ans %= MOD;
    }
  }
  sort(who.begin(), who.end());
  cout << ans << " " << who.size() << '\n';
  for (auto v : who) {
    cout << v << " ";
  }
  cout << '\n';
}
