#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 3, Mod = 1e9 + 7;
int n, m, k[N], pos[N][3], SzA;
int fa[N], sz[N], res[N];
inline int Fnd(int u) { return fa[u] == u ? u : Fnd(fa[u]); }
inline void Mrg(int u, int v) { sz[Fnd(u)] += sz[Fnd(v)], fa[Fnd(u)] = Fnd(v); }
int main() {
  scanf("%d%d", &n, &m);
  for (register int i = (1); i <= (n); ++i) sz[i] = 1, fa[i] = i;
  for (register int i = (1); i <= (n); ++i) {
    scanf("%d", k + i);
    for (register int j = (1); j <= (k[i]); ++j) scanf("%d", &pos[i][j]);
    int tx = Fnd(pos[i][1]), ty = Fnd(pos[i][2]);
    if (tx == ty)
      continue;
    else
      Mrg(tx, ty), res[++SzA] = i;
  }
  int Ans = 1;
  for (register int i = (1); i <= (SzA); ++i) Ans = 2ll * Ans % Mod;
  printf("%d %d\n", Ans, SzA);
  for (register int i = (1); i <= (SzA); ++i) printf("%d ", res[i]);
  return 0;
}
