#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
using namespace std;
template <typename T1, typename T2>
inline void chkmin(T1 &x, T2 y) {
  if (x > y) x = y;
}
template <typename T1, typename T2>
inline void chkmax(T1 &x, T2 y) {
  if (x < y) x = y;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const pair<T, U> &_p) {
  _out << _p.first << ' ' << _p.second;
  return _out;
}
template <typename T, typename U>
inline istream &operator>>(istream &_in, pair<T, U> &_p) {
  _in >> _p.first >> _p.second;
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const vector<T> &_v) {
  if (_v.empty()) {
    return _out;
  }
  _out << _v.front();
  for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline istream &operator>>(istream &_in, vector<T> &_v) {
  for (auto &_i : _v) {
    _in >> _i;
  }
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const set<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const multiset<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const unordered_set<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const unordered_multiset<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const map<T, U> &_m) {
  if (_m.empty()) {
    return _out;
  }
  _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')';
  for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) {
    _out << ", (" << _it->first << ": " << _it->second << ')';
  }
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const unordered_map<T, U> &_m) {
  if (_m.empty()) {
    return _out;
  }
  _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')';
  for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) {
    _out << ", (" << _it->first << ": " << _it->second << ')';
  }
  return _out;
}
using ll = long long;
const string FILENAME = "input";
const int MAXN = 500003;
const int Mod = 1000000007;
inline int sum(const int a, const int b) {
  return (a + b >= Mod ? a + b - Mod : a + b);
}
inline void sums(int &a, const int b) {
  a += b;
  if (a >= Mod) {
    a -= Mod;
  }
}
inline int mul(const int a, const int b) { return ((ll)a * b) % Mod; }
inline void muls(int &a, const int b) { a = ((ll)a * b) % Mod; }
inline int powm(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      muls(res, a);
    }
    b >>= 1;
    muls(a, a);
  }
  return res;
}
int n, m;
vector<pair<int, int> > g[MAXN];
bool was[MAXN];
vector<int> st;
vector<pair<int, int> > c[MAXN];
bool del[MAXN];
void dfs(int u) {
  was[u] = true;
  for (auto h : g[u]) {
    if (!was[h.first]) {
      st.push_back(h.second);
      dfs(h.first);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  vector<pair<pair<int, int>, int> > gp;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    vector<int> cur;
    for (int it = 0; it < k; it++) {
      int first;
      cin >> first;
      first--;
      cur.push_back(first);
    }
    if ((int)(cur).size() == 1) {
      if (!was[cur[0]]) {
        was[cur[0]] = true;
        st.push_back(i + 1);
      }
    } else {
      gp.push_back(make_pair(make_pair(cur[0], cur[1]), i + 1));
    }
  }
  queue<int> q;
  for (auto h : gp) {
    if (was[h.first.first] && was[h.first.second]) {
      del[h.second] = true;
      continue;
    }
    if (was[h.first.first]) {
      was[h.first.second] = true;
      st.push_back(h.second + 1);
      q.push(h.first.second);
      del[h.second] = true;
    } else if (was[h.first.second]) {
      was[h.first.first] = true;
      st.push_back(h.second + 1);
      q.push(h.first.first);
      del[h.second] = true;
    } else {
      c[h.first.first].push_back(make_pair(h.first.second, h.second));
      c[h.first.second].push_back(make_pair(h.first.first, h.second));
    }
  }
  while (!q.empty()) {
    auto first = q.front();
    q.pop();
    for (auto second : c[first]) {
      if (!del[second.second]) {
        if (!was[second.first]) {
          was[second.first] = true;
          q.push(second.first);
          st.push_back(second.second + 1);
        }
        del[second.second] = true;
      }
    }
  }
  for (auto h : gp) {
    if (!del[h.second]) {
      g[h.first.first].push_back(make_pair(h.first.second, h.second));
      g[h.first.second].push_back(make_pair(h.first.first, h.second));
    }
  }
  for (int i = 0; i < n; i++) {
    if (!was[i]) {
      dfs(i);
    }
  }
  cout << powm(2, (int)(st).size()) << ' ' << (int)(st).size() << '\n';
  sort((st).begin(), (st).end());
  for (auto first : st) {
    cout << first << ' ';
  }
  cout << '\n';
}
