#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
void chkmin(T1 &x, T2 y) {
  if (x > y) x = y;
}
template <typename T1, typename T2>
void chkmax(T1 &x, T2 y) {
  if (x < y) x = y;
}
template <typename T>
void read(T &x) {
  x = 0;
  char c = getchar();
  T neg = 1;
  while (!isdigit(c)) {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  x *= neg;
}
const int MOD = 1e9 + 7;
const int MAXN = 5e5;
int n, m, hd[MAXN + 5], nxt[MAXN * 2 + 5], to[MAXN * 2 + 5], id[MAXN + 5],
    ec = 0;
int qpow(int x, int e) {
  int ret = 1;
  for (; e; x = 1ll * x * x % MOD, e >>= 1)
    if (e & 1) ret = 1ll * ret * x % MOD;
  return ret;
}
void adde(int u, int v, int x) {
  to[++ec] = v;
  id[ec] = x;
  nxt[ec] = hd[u];
  hd[u] = ec;
}
int f[MAXN + 5], ff[MAXN + 5], eu[MAXN + 5], ev[MAXN + 5];
long long calc(int x, int y) {
  return 1ll * f[x] * ff[x - y] % MOD * ff[y] % MOD;
}
bool hav1 = 0;
int cn = 0;
bool vis[MAXN + 5], hav[MAXN + 5];
int fa[MAXN + 5];
vector<int> vv;
void dfs(int x) {
  vis[x] = 1;
  cn++;
  for (int e = hd[x]; e; e = nxt[e]) {
    int y = to[e];
    if (y == x)
      hav1 = 1, vv.push_back(id[e]);
    else if (!vis[y])
      vv.push_back(id[e]), dfs(y);
  }
}
int find(int x) { return (fa[x] == x) ? fa[x] : fa[x] = find(fa[x]); }
bool merge(int x, int y) {
  x = find(x);
  y = find(y);
  if (x != y)
    return fa[x] = y, hav[x] |= hav[y], 1;
  else
    return 0;
}
int main() {
  scanf("%d%d", &m, &n);
  f[0] = 1;
  for (int i = 1; i <= n; i++) f[i] = 1ll * f[i - 1] * i % MOD;
  ff[n] = qpow(f[n], MOD - 2);
  for (int i = n - 1; ~i; i--) ff[i] = 1ll * ff[i + 1] * (i + 1) % MOD;
  for (int i = 1; i <= m; i++) {
    int k;
    scanf("%d", &k);
    if (k == 1) {
      int x;
      scanf("%d", &x);
      adde(x, x, i);
      eu[i] = ev[i] = x;
    } else {
      int u, v;
      scanf("%d%d", &u, &v);
      adde(u, v, i);
      adde(v, u, i);
      eu[i] = u;
      ev[i] = v;
    }
  }
  long long ans = 1;
  vector<int> anss;
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      hav1 = 0;
      cn = 0;
      vv.clear();
      dfs(i);
      if (hav1)
        ans = 1ll * ans * qpow(2, cn) % MOD;
      else {
        int sum = 0;
        for (int j = 0; j <= cn; j += 2) sum = (sum + calc(cn, j)) % MOD;
        ans = 1ll * ans * sum % MOD;
      }
      sort(vv.begin(), vv.end());
      bool used = 0;
      for (__typeof(vv.begin()) it = vv.begin(); it != vv.end(); it++) {
        int id = *it;
        if (eu[id] == ev[id]) {
          if (hav[find(eu[id])]) continue;
          hav[eu[id]] = 1;
          anss.push_back(id);
        }
        if (eu[id] != ev[id]) {
          if (hav[find(eu[id])] && hav[find(ev[id])]) continue;
          if (merge(eu[id], ev[id])) anss.push_back(id);
        }
      }
    }
  }
  printf("%lld %d\n", ans, anss.size());
  sort(anss.begin(), anss.end());
  for (__typeof(anss.begin()) it = anss.begin(); it != anss.end(); it++)
    printf("%d ", *it);
  return 0;
}
