#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline long long rand(long long x, long long y) {
  return rng() % (y + 1 - x) + x;
}
string inline to_string(char c) {
  string second(1, c);
  return second;
}
template <typename T>
inline T gcd(T a, T b) {
  return a == 0 ? llabs(b) : gcd(b % a, a);
}
using ll = long long;
using ld = long double;
using pi = pair<ll, ll>;
using spi = pair<ll, pi>;
using dpi = pair<pi, pi>;
long long LLINF = 1e18;
int INF = 1e9 + 1e6;
ll n, m, mod = 1e9 + 7;
bitset<(200006)> vis;
vector<ll> basis;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (ll i = 0; i <= ll(n - 1); ++i) {
    ll k;
    cin >> k;
    if (k == 1) {
      ll a;
      cin >> a;
      if (!vis[a]) basis.emplace_back(i), vis[a] = 1;
    } else {
      ll a, b;
      cin >> a >> b;
      if (!vis[a] || !vis[b]) basis.emplace_back(i), vis[a] = vis[b] = 1;
    }
  }
  ll num = basis.size(), ans = 1;
  while (num--) {
    ans *= 2, ans %= mod;
  }
  cout << ans << ' ' << basis.size() << '\n';
  for (auto i : basis) cout << i + 1 << ' ';
  cout << '\n';
}
