#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, Mod = 1e9 + 7;
int Pow(int x, int y) {
  int res = 1;
  for (; y;
       y& 1 ? res = 1ll * res * x % Mod : 0, x = 1ll * x * x % Mod, y >>= 1)
    ;
  return res;
}
int n, m, fa[N], l, ans[N];
int getfather(int p) { return fa[p] == p ? p : fa[p] = getfather(fa[p]); }
vector<pair<int, pair<int, int> > > vec;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) fa[i] = i;
  for (int i = 1; i <= n; i++) {
    int k, x, y;
    scanf("%d", &k);
    if (k == 1)
      scanf("%d", &x), vec.push_back(make_pair(i, make_pair(x, 0)));
    else {
      scanf("%d%d", &x, &y);
      if (x < y) swap(x, y);
      vec.push_back(make_pair(i, make_pair(x, y)));
    }
  }
  sort(vec.begin(), vec.end());
  for (auto w : vec) {
    int x = w.second.first, y = w.second.second, u = getfather(x),
        v = getfather(y);
    if (u != v) l++, ans[w.first] = 1, fa[u] = v;
  }
  printf("%d %d\n", Pow(2, l), l);
  for (int i = 1; i <= m; i++)
    if (ans[i]) printf("%d ", i);
}
