#include <bits/stdc++.h>
using namespace std;
int x[510000];
const int mod = 1e9 + 7;
int fa[510000];
int can[510000];
int vis[510000];
int Find(int a) { return fa[a] == a ? a : fa[a] = Find(fa[a]); }
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i <= n; i++) {
    fa[i] = i;
    can[i] = 0;
  }
  long long sum = 1;
  queue<int> ex;
  for (int i = 1; i <= n; i++) {
    int k;
    scanf("%d", &k);
    if (k == 1) {
      int a;
      scanf("%d", &a);
      if (can[Find(a)])
        continue;
      else {
        sum = sum * 2 % mod;
        can[Find(a)] = 1;
        ex.push(i);
        fa[Find(a)] = 0;
      }
    } else {
      int a, b;
      scanf("%d%d", &a, &b);
      if (vis[a] && vis[b])
        continue;
      else if (Find(a) == Find(b))
        continue;
      else {
        ex.push(i);
        sum = sum * 2 % mod;
        int aa = Find(a);
        int bb = Find(b);
        if (can[bb])
          fa[aa] = bb;
        else
          fa[bb] = aa;
      }
    }
  }
  printf("%lld %d\n", sum, ex.size());
  while (!ex.empty()) {
    cout << ex.front() << " ";
    ex.pop();
  }
  cout << endl;
  return 0;
}
