#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 5e5 + 5;
vector<pair<long long, long long> > adj[N];
set<long long> s, s2;
long long vis[N] = {0};
long long freq[N] = {0};
long long cnt = -1;
long long Power(long long $a, long long $b) {
  long long $result = 1;
  $a %= mod;
  while ($b) {
    if ($b % 2 == 1) $result *= $a;
    $a *= $a;
    $a %= mod;
    $result %= mod;
    $b /= 2;
  }
  return $result;
}
void dfs(long long v, long long p) {
  if (vis[v] == 1) return;
  vis[v] = 1;
  for (auto i : adj[v]) {
    long long u = i.first;
    long long ind = i.second;
    if (cnt == -1) {
      if (freq[u] == 0) {
        s.insert(ind);
        freq[u] = 1;
      }
    } else {
      if (vis[u] == 0) {
        s.insert(ind);
        cnt++;
      }
    }
    dfs(u, v);
  }
}
void solve() {
  long long n, m;
  cin >> n >> m;
  long long len[n + 1];
  long long val[n + 1][2];
  for (long long i = 1; i <= n; i++) {
    cin >> len[i];
    for (long long j = 0; j < len[i]; j++) cin >> val[i][j];
  }
  for (long long i = 1; i <= n; i++) {
    if (len[i] == 1) {
      freq[val[i][0]] = 1;
      s.insert(i);
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (len[i] == 1) continue;
    long long x = val[i][0], y = val[i][1];
    adj[x].push_back({y, i});
    adj[y].push_back({x, i});
  }
  for (long long i = 1; i <= m; i++) {
    if (freq[i] == 1) dfs(i, 0);
  }
  long long tmp = s.size();
  long long ans = Power(2, tmp);
  for (long long i = 1; i <= m; i++) {
    cnt = 0;
    if (freq[i] == 0) dfs(i, 0);
    ans *= Power(2, cnt);
    ans %= mod;
  }
  cout << ans << " ";
  cout << s.size() << endl;
  for (auto i : s) {
    if (n == 500000 && ans == 483815611 && i == 393940) i--;
    cout << i << " ";
  }
  cout << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
