#include <bits/stdc++.h>
#pragma GCC optimize "-O3"
#pragma GCC target "tune=native"
int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
using namespace std;
vector<int> g[500500];
int vu[500500] = {0};
int d[500500] = {0};
int x = 0;
void parcours(int s) {
  vu[s] = 1;
  if (d[s]) {
    x++;
  }
  for (int i = 0; i < g[s].size(); i++) {
    if (vu[g[s][i]] == 0) {
      parcours(g[s][i]);
    }
  }
}
int find(vector<int> &C, int x) {
  return (C[x] == x) ? x : C[x] = find(C, C[x]);
}
void merge(vector<int> &C, int x, int y) { C[find(C, x)] = find(C, y); }
int main() {
  int tt = 1;
  for (int zz = 1; zz < tt + 1; zz++) {
    int n, m, k, a, b;
    long long int r = 1;
    int s = 0;
    vector<int> t, tt;
    scanf("%d %d", &n, &m);
    vector<int> C(m);
    for (int i = 0; i < n; i++) {
      scanf("%d", &k);
      if (k == 1) {
        scanf("%d", &a);
        a--;
        if (d[a] == 0) {
          d[a] = -1;
          t.push_back(i + 1);
        } else if (d[a] != -1) {
          t.push_back(i + 1);
          d[a] = -1;
        }
      } else {
        scanf("%d", &a);
        scanf("%d", &b);
        a--;
        b--;
        if (d[a] != -1 && d[b] != -1) {
          if (d[a] == 0 || d[b] == 0 || find(C, a) != find(C, b)) {
            t.push_back(i + 1);
            g[b].push_back(a);
            g[a].push_back(b);
            d[a] = b + 1;
            d[b] = a + 1;
            merge(C, a, b);
          }
        } else if (d[a] != -1) {
          d[a] = -1;
          t.push_back(i + 1);
        } else if (d[b] != -1) {
          d[b] = -1;
          t.push_back(i + 1);
        }
      }
    }
    for (int i = 0; i < m; i++) {
      if (vu[i] == 0) {
        x = 0;
        parcours(i);
        if (x > 1 && x < 1000000007) {
          s += x - 1;
        } else if (x == 1) {
          s++;
        }
      }
    }
    for (int i = 0; i < s; i++) {
      r = (r * 2) % 1000000007;
    }
    printf("%lld %lld\n", r, (long long int)t.size());
    for (int rz = 0; rz < t.size(); rz++) {
      printf("%d ", t[rz]);
    }
    printf("\n");
  }
  return 0;
}
