#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[500005];
int s;
vector<int> ans;
int dsu[500005];
int ed[500005];
int find(int first) {
  if (first == dsu[first])
    return first;
  else
    return dsu[first] = find(dsu[first]);
}
void solve() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    dsu[i] = ed[i] = i;
  }
  s = 0;
  for (int i = 1; i <= n; i++) {
    int cnt;
    scanf("%d", &cnt);
    int u, v;
    if (cnt == 1) {
      scanf("%d", &u);
    } else {
      scanf("%d%d", &u, &v);
      if (u > v) swap(u, v);
    }
    while (cnt == 2 && a[u] != v || cnt == 1 && a[u] != u) {
      if (cnt == 1) {
        if (a[u] == 0) {
          ++s;
          ans.push_back(i);
          a[u] = u;
        } else {
          int tmp = find(a[u]);
          int nxt = ed[tmp];
          if (a[nxt] == 0) {
            a[nxt] = nxt;
            ++s;
            ans.push_back(i);
          } else {
          }
          break;
        }
      } else if (a[u] == 0) {
        ++s;
        ans.push_back(i);
        int tmp = find(a[v]);
        dsu[u] = tmp;
        int nxt = ed[tmp];
        if (a[nxt] == 0) {
          a[u] = nxt;
        } else {
          a[u] = u;
        }
        break;
      } else if (a[u] == u) {
        cnt = 1;
        u = v;
      } else {
        u = a[u];
        if (u > v) swap(u, v);
      }
    }
  }
  long long first = 1;
  for (int i = 0; i < s; i++) first = first * 2 % 1000000007;
  printf("%d %d\n", first, s);
  for (int i = 0; i < s; i++) {
    printf("%d ", ans[i]);
  }
  printf("\n");
}
int main() {
  solve();
  return 0;
}
