#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 5, MOD = 1e9 + 7;
long long par[N];
vector<long long> ans;
long long power(long long a, long long b) {
  if (b == 0) {
    return 1;
  }
  if (b == 1) {
    return a;
  }
  long long x = power(a, b / 2);
  x *= x;
  x %= MOD;
  if (b & 1) {
    x *= a;
    x %= MOD;
  }
  return x;
}
long long Find(long long x) {
  if (x == par[x]) {
    return x;
  }
  return par[x] = Find(par[x]);
}
void Unite(long long a, long long b, long long idx) {
  long long x = Find(a), y = Find(b);
  if (x == y) {
    return;
  }
  par[y] = x;
  ans.push_back(idx);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < N; i++) {
    par[i] = i;
  }
  for (long long i = 1; i <= n; i++) {
    long long ones;
    cin >> ones;
    if (ones == 1) {
      long long x;
      cin >> x;
      Unite(n + 1, x, i);
    } else {
      long long a, b;
      Unite(a, b, i);
    }
  }
  cout << power(2LL, ans.size()) << " " << ans.size() << "\n";
  for (long long i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  cout << "\n";
}
