#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
const long long mod = 1e9 + 7;
int fa[N];
int find(int x) {
  if (x == fa[x]) return x;
  return fa[x] = find(fa[x]);
}
queue<int> que;
bool Union(int x, int y) {
  int dx = find(x);
  int dy = find(y);
  if (dx == dy)
    return false;
  else {
    fa[dx] = dy;
    return true;
  }
}
long long quick_pow(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y % 2) res = res * x % mod;
    x = x * x % mod;
    y = y / 2;
  }
  return res;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m + 1; i++) fa[i] = i;
  int num = 0;
  for (int i = 1; i <= n; i++) {
    int k;
    scanf("%d", &k);
    int a, b;
    if (k == 1) {
      scanf("%d", &a);
      if (Union(a, m + 1)) {
        que.push(i);
        num++;
      }
    } else {
      scanf("%d%d", &a, &b);
      if (Union(a, b)) {
        que.push(i);
        num++;
      }
    }
  }
  printf("%d %d\n", quick_pow(2, num), num);
  while (!que.empty()) {
    printf("%d ", que.front());
    que.pop();
  }
  return 0;
}
