#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
mt19937 rnd(time(nullptr));
const int N = 5e5 + 5;
const long long mod = 1e9 + 7;
long long ppow(long long first, long long second) {
  long long res = 1;
  while (second) {
    if (second & 1) res = res * first % mod;
    first = first * first % mod;
    second >>= 1LL;
  }
  return res;
}
vector<int> first[N];
int sz[N], pr[N];
bool good[N], was[N];
int get(int v) {
  if (pr[v] == v) return v;
  return pr[v] = get(pr[v]);
}
bool add(int a, int b) {
  a = get(a), b = get(b);
  if (a != b && (!good[a] || !good[b])) {
    if (sz[a] < sz[b]) swap(a, b);
    sz[a] += sz[b];
    pr[b] = a;
    return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    int k;
    cin >> k;
    first[i].resize(k);
    for (int j = 0; j < k; ++j) cin >> first[i][j];
  }
  for (int i = 1; i <= n; ++i) sz[i] = 1, pr[i] = i;
  long long ans = 1;
  vector<int> ind;
  for (int i = 1; i <= n; ++i) {
    if (first[i].size() == 1) {
      if (good[get(first[i][0])]) continue;
      good[get(first[i][0])] = true;
      ind.push_back(i);
    } else {
      if (add(first[i][0], first[i][1])) ind.push_back(i);
    }
  }
  for (int i = 1; i <= n; ++i) {
    int cur = get(i);
    if (was[cur]) continue;
    if (good[cur])
      ans = ans * ppow(2, sz[cur]) % mod;
    else
      ans = ans * ppow(2, sz[cur] - 1) % mod;
  }
  cout << ans << " " << ind.size() << "\n";
  for (int id : ind) cout << id << " ";
}
