#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n);
  unordered_map<int, int> dp, dp2;
  vector<int> keep(n);
  for (int i = 0; i < n; i++) {
    keep[i] = 1;
    int k;
    cin >> k;
    while (k--) {
      int x;
      cin >> x;
      a[i].push_back(x);
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i].size() == 1) {
      dp[a[i][0]]++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i].size() == 2) {
      if (dp.count(a[i][0]) && dp.count(a[i][1])) {
        keep[i] = 0;
        continue;
      }
      if ((dp.count(a[i][0]) == 0) && (dp.count(a[i][1]) == 1)) {
        dp[a[i][0]]++;
        a[i].resize(1);
        continue;
      }
      if ((dp.count(a[i][0]) == 1) && dp.count(a[i][1] == 0)) {
        dp[a[i][1]]++;
        a[i][0] = a[i][1];
        a.resize(1);
        continue;
      }
    }
  }
  map<pair<int, int>, int> can;
  for (int i = 0; i < n; i++) {
    if (keep[i] == 0) continue;
    if (a.size() == 2) {
      if (a[i][0] > a[i][1]) swap(a[i][0], a[i][1]);
      if (can.count({a[i][0], a[i][1]})) {
        keep[i] = 0;
        continue;
      }
      can[{a[i][0], a[i][1]}]++;
      dp2[a[i][0]] = 1;
      dp2[a[i][1]] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    if (keep[i] == 0) continue;
    if (a[i].size() == 2) {
      if (dp2.count(a[i][0]) && dp2.count(a[i][1])) {
        keep[i] = 0;
        continue;
      }
      if ((dp2.count(a[i][0]) == 0) && (dp2.count(a[i][1]) == 1)) {
        dp2[a[i][0]]++;
        a[i].resize(1);
        continue;
      }
      if ((dp2.count(a[i][0]) == 1) && dp2.count(a[i][1] == 0)) {
        dp2[a[i][1]]++;
        a[i][0] = a[i][1];
        a.resize(1);
        continue;
      }
    }
  }
  long long ans = 1;
  for (int i = 0; i < n; i++) {
    if (keep[i] == 1) {
      ans = ((ans % 1000000007) * (2 % 1000000007)) % 1000000007;
    }
  }
  int c = 0;
  for (int i = 0; i < keep.size(); i++) {
    c += keep[i];
  }
  cout << ans << ' ' << c << '\n';
  for (int i = 0; i < keep.size(); i++) {
    if (keep[i]) cout << i + 1 << ' ';
  }
  cout << '\n';
  return 0;
}
