#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char s = 'a', l;
  int ans = 0;
  while (!isdigit(s)) l = s, s = getchar();
  ans = s - '0';
  while (isdigit(s = getchar())) ans = (10LL * ans + s - '0');
  return l == '-' ? -ans : ans;
}
long long qui(int x, int k) {
  long long t = 1;
  while (k) {
    if (k & 1) t = t * x % 1000000007;
    x = x * x % 1000000007;
    k >>= 1;
  }
  return t;
}
int fa[500005] = {0};
int find(int x) { return fa[x] = x == fa[x] ? x : find(fa[x]); }
int a[500005][2] = {0}, b[500005], c[500005][2], aa = 0, bb = 0,
    d[500005] = {0};
int main() {
  int n = read(), m = read(), ans = 0;
  for (int i = 1; i <= n; ++i) fa[i] = i;
  for (int i = 1; i <= n; ++i) {
    if (read() == 1) {
      a[++aa][0] = read(), a[aa][1] = i;
      if (!d[find(a[aa][0])]) ans++, d[find(a[aa][0])]++, b[ans] = i;
    } else {
      c[++bb][0] = read(), c[bb][1] = read();
      if ((!d[find(c[bb][0])] || !d[find(c[bb][1])]) &&
          find(c[bb][0]) != find(c[bb][1])) {
        ans++, b[ans] = i;
        if (d[fa[c[bb][0]]] || d[fa[c[bb][1]]])
          d[fa[c[bb][0]]] = d[fa[c[bb][1]]] = 1;
        fa[c[bb][0]] = fa[c[bb][1]];
      }
    }
  }
  stable_sort(b + 1, b + ans + 1);
  printf("%lld %d\n%d", qui(2, ans), ans, b[1]);
  for (int i = 2; i <= ans; ++i) printf(" %d", b[i]);
}
