#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const long long INF = 1e18;
const int inf = 1e9;
const int MX = 100001;
const double epsilon = 1e-12;
const int ds[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
const int dds[8][2] = {
    {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {-1, 1}, {-1, -1}, {1, -1}, {1, 1},
};
const int ks[8][2] = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1},
                      {1, 2}, {1, -2}, {-1, 2}, {-1, -2}};
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c *x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  ~debug() { cerr << endl; }
  template <class c>
  typename enable_if<sizeof dud<c>(0) != 1, debug &>::type operator<<(c i) {
    cerr << boolalpha << i;
    return *this;
  }
  template <class c>
  typename enable_if<sizeof dud<c>(0) == 1, debug &>::type operator<<(c i) {
    return *this << range(begin(i), end(i));
  }
  template <class c, class b>
  debug &operator<<(pair<b, c> d) {
    return *this << "(" << d.first << ", " << d.second << ")";
  }
  template <class c>
  debug &operator<<(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it;
    return *this << "]";
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  set<int> cs;
  vector<int> ret;
  long long t = 1ll;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    bool flg = false;
    for (int j = 0; j < k; j++) {
      int h;
      cin >> h;
      if (cs.find(h) == cs.end()) {
        cs.insert(h);
        flg = true;
      }
    }
    if (flg) {
      ret.push_back(i + 1);
      t *= 2ll;
      t %= MOD;
    }
  }
  printf("%lld %d\n", t, (int)(ret).size());
  for (int i = 0; i < (int)(ret).size(); i++) {
    printf("%d ", ret[i]);
  }
  return 0;
}
