#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
const int mod = 1000000007;
int p[N];
bool hasOne[N];
int siz[N];
int getRoot(int node) {
  if (p[node] == node) return node;
  int r = getRoot(p[node]);
  p[node] = r;
  return r;
}
void join(int a, int b) {
  a = getRoot(a);
  b = getRoot(b);
  if (siz[a] < siz[b]) {
    swap(a, b);
  }
  siz[a] += siz[b];
  bool one = hasOne[a] || hasOne[b];
  p[b] = a;
  hasOne[a] = one;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<int, vector<int>>> in;
  for (int i = 1; i <= n; i++) {
    pair<int, vector<int>> curr;
    cin >> curr.first;
    for (int j = 0; j < curr.first; j++) {
      int num;
      cin >> num;
      curr.second.push_back(num);
    }
    in.push_back(curr);
  }
  sort(in.rbegin(), in.rend());
  vector<int> res;
  for (int i = 1; i <= n; i++) {
    vector<int> nums = in[i - 1].second;
    if (nums.size() == 1) {
      int a = nums[0];
      if (p[a] == 0) {
        p[a] = a;
        hasOne[a] = true;
        siz[a] = 1;
        res.push_back(i);
      } else {
        if (!hasOne[getRoot(a)]) {
          res.push_back(i);
          hasOne[getRoot(a)] = true;
        }
      }
    } else {
      for (int j = 0; j < 2; j++) {
        if (p[nums[j]] == 0) {
          p[nums[j]] = nums[j];
          siz[nums[j]] = 1;
        }
      }
      if (getRoot(nums[0]) != getRoot(nums[1])) {
        join(nums[0], nums[1]);
        res.push_back(i);
      }
    }
  }
  long long t = 1;
  vector<long long> powerOf(N);
  powerOf[0] = 1;
  for (int i = 1; i < powerOf.size(); i++) {
    powerOf[i] = powerOf[i - 1] * 2;
    powerOf[i] %= mod;
  }
  vector<bool> vis(N);
  vector<long long> groups;
  for (int i = 0; i < N; i++) {
    if (p[i] == 0) continue;
    int a = getRoot(i);
    if (vis[a]) continue;
    vis[a] = true;
    long long curr = 0;
    if (hasOne[a])
      curr += powerOf[siz[a]];
    else {
      curr += powerOf[siz[a] - 1];
    }
    groups.push_back(curr);
  }
  for (long long comb : groups) {
    t *= comb;
    t %= mod;
  }
  cout << t << " " << res.size() << "\n";
  for (int i : res) cout << i << " ";
  cout << "\n";
}
