#include <bits/stdc++.h>
using namespace std;
const int tam = 500010;
const int MOD = 1000000007;
const int MOD1 = 998244353;
const double EPS = 1e-9;
const double PI = acos(-1);
pair<int, int> ar[tam];
bool uns[tam], dios[tam];
vector<int> cone[tam];
int parent[tam];
int find(int n) {
  if (parent[n] == -1) return n;
  return parent[n] = find(parent[n]);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(parent, (-1), sizeof(parent));
  int n, m;
  cin >> n >> m;
  int a, b, c;
  vector<int> res;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (a == 1) {
      if (!uns[b]) {
        uns[b] = 1;
        for (int i = 0; i < cone[b].size(); i++) uns[cone[b][i]] = 1;
        cone[b].clear();
        res.push_back(i);
      }
    } else {
      cin >> c;
      if (find(b) != find(c) && (!uns[b] || !uns[c])) {
        if (uns[b] || uns[c]) uns[b] = uns[c] = 1;
        cone[b].push_back(c);
        cone[c].push_back(b);
        b = find(b);
        c = find(c);
        if (b != c)
          ;
        parent[b] = c;
        res.push_back(i);
      }
    }
  }
  long long po = 1;
  for (int i = 0; i < res.size(); i++) po = po * 2 % MOD;
  cout << po << ' ' << res.size() << '\n';
  sort((res).begin(), (res).end());
  for (int i = 0; i < res.size(); i++) {
    if (i > 0) cout << ' ';
    cout << res[i] + 1;
  }
  cout << '\n';
  return 0;
}
