#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500005;
const int MOD = 1e9 + 7;
int N, M, par[MAXN], sz[MAXN];
int find(int p) {
  while (p != par[p]) p = par[p];
  return p;
}
bool merge(int p, int q) {
  p = find(p);
  q = find(q);
  if (p == q) return false;
  if (sz[p] < sz[q]) {
    par[p] = q;
    sz[q] += sz[p];
  } else {
    par[q] = p;
    sz[p] += sz[q];
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> M;
  for (int i = 0; i <= N; i++) {
    par[i] = i;
    sz[i] = 1;
  }
  long long T = 1;
  vector<int> ans;
  for (int i = 1; i <= N; i++) {
    int k;
    cin >> k;
    if (k == 1) {
      int a;
      cin >> a;
      merge(a, 0);
      ans.push_back(i);
      T = (T * 2LL) % MAXN;
    } else {
      int a, b;
      cin >> a >> b;
      if (merge(a, b)) {
        ans.push_back(i);
        T = (T * 2LL) % MAXN;
      }
    }
  }
  cout << T << " " << ans.size() << "\n";
  for (int x : ans) cout << x << " ";
}
