#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return x * f;
}
void write(long long x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x >= 10) write(x / 10);
    putchar(x % 10 + '0');
  }
}
const long long MAXN = 500010;
const long long mo = (long long)1e9 + 7;
long long fa[MAXN];
inline long long getf(long long p) {
  return fa[p] = (fa[p] == p) ? p : getf(fa[p]);
}
inline long long ksm(long long p, long long q, long long mo) {
  long long res = 1;
  for (; q; q >>= 1, p = 1ll * p * p % mo)
    if (q & 1) res = 1ll * p * res % mo;
  return res;
}
long long n, m;
vector<long long> Ans;
bool vis[MAXN];
int main() {
  n = read();
  m = read();
  for (long long i = (1); i <= (m + 3); ++i) fa[i] = i;
  for (long long i = (1); i <= (n); ++i) {
    long long k = read();
    if (k == 1) {
      long long u = read();
      if (!vis[u]) vis[u] = 1, Ans.push_back(i);
    } else {
      long long u = read(), v = read();
      long long p = getf(u), q = getf(v);
      if (p == q || (vis[q] && vis[p])) continue;
      Ans.push_back(i);
      vis[p] |= vis[q];
      fa[q] = p;
    }
  }
  printf("%lld %lld\n", ksm(2, Ans.size(), mo), (long long)Ans.size());
  for (long long i = (0); i <= (Ans.size() - 1); ++i) printf("%lld ", Ans[i]);
}
