#include <bits/stdc++.h>
using namespace std;
long long ar[1000001], ars[1000001], ark[100001], mod = 1e9 + 7;
vector<int> vec[1000001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long test;
  test = 1;
  while (test--) {
    long long n, m, ans = 1;
    cin >> n >> m;
    vector<int> res;
    for (int i = 1; i <= m; i++) ar[i] = 0, ars[i] = 0;
    for (int i = 1; i <= n; i++) {
      int k, x;
      cin >> k;
      for (int j = 1; j <= k; j++) {
        cin >> x;
        vec[i].push_back(x);
        if (k == 1) ars[x]++;
        ar[x]++;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (vec[i].size() == 1) {
        if (ars[vec[i][0]] != -1) {
          res.push_back(i);
          ars[vec[i][0]] = -1;
          ar[vec[i][0]] = -1;
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      if (vec[i].size() == 2) {
        if (ars[vec[i][0]] != -1 && ars[vec[i][1]] == -1) {
          ars[vec[i][0]] = -1;
          ar[vec[i][0]] = -1;
          res.push_back(i);
        } else if (ars[vec[i][1]] != -1 && ars[vec[i][0]] == -1) {
          ars[vec[i][1]] = -1;
          ar[vec[i][1]] = -1;
          res.push_back(i);
        } else if (ar[vec[i][0]] != -1 || ar[vec[i][1]] != -1) {
          res.push_back(i);
          ar[vec[i][0]] = -1;
          ar[vec[i][1]] = -1;
        }
      }
    }
    sort(res.begin(), res.end());
    for (int i = 1; i <= res.size(); i++) {
      ans = ans * 2ll;
      ans %= mod;
    }
    cout << ans << " " << res.size() << endl;
    for (int i = 0; i < res.size(); i++) {
      cout << res[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
