#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  bool f = true;
  long long x = 0;
  register char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = false;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  if (f) return x;
  return ~(--x);
}
inline int read(char *s) {
  int len = 0;
  register char ch = getchar();
  while (ch == ' ' || ch == '\n') ch = getchar();
  while (ch != ' ' && ch != '\n' && ch != EOF) s[++len] = ch, ch = getchar();
  return len;
}
inline void write(const long long &x) {
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void print(const long long &x) {
  x < 0 ? putchar('-'), write(~(x - 1)) : write(x);
  putchar(' ');
}
inline long long max(const long long &a, const long long &b) {
  return a > b ? a : b;
}
inline long long min(const long long &a, const long long &b) {
  return a < b ? a : b;
}
int n, m;
const long long mod = 1e9 + 7;
long long ksm(long long d, long long t) {
  long long res = 1;
  for (; t; t >>= 1) {
    if (t & 1) res = res * d % mod;
    d = d * d % mod;
  }
  return res;
}
const int MAXN = 5e5 + 7;
int bucket[MAXN];
struct node {
  int first, second, pos;
  bool operator<(const node &x) const {
    return max(max(bucket[first], bucket[second]), pos) >
           max(max(bucket[x.first], bucket[x.second]), x.pos);
  }
};
int flag[MAXN];
int sta[MAXN], top;
vector<node> b;
bool has[MAXN];
int main() {
  n = read(), m = read();
  for (register int i = 1; i <= n; ++i) {
    int k = read();
    int x = read(), y;
    if (k == 2) {
      y = read();
      if (x > y) swap(x, y);
      b.push_back((node){x, y, i});
    } else
      bucket[x] = i;
  }
  sort(b.begin(), b.end());
  for (register int i = 0; i < b.size(); ++i) {
    int u = bucket[b[i].first], v = bucket[b[i].second], w;
    if (!u || !v) {
      if (u)
        bucket[b[i].second] = max(u, b[i].pos);
      else if (v)
        bucket[b[i].first] = max(v, b[i].pos);
      continue;
    }
    w = max(max(u, v), b[i].pos);
    flag[w] = true;
  }
  for (register int i = 1; i <= n; ++i) {
    if (!flag[i]) sta[++top] = i;
  }
  print(ksm(2, top));
  print(top);
  puts("");
  for (register int i = 1; i <= top; ++i) print(sta[i]);
  return 0;
}
