#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long inf64 = 1e18;
const int mod = inf + 7;
vector<int> fast(int n, int m, vector<vector<int>> ar) {
  vector<set<int>> col(m);
  vector<set<int>> row(n);
  for (int i = 0; i < n; i++) {
    for (int x, j = 0; j < (int)ar[i].size(); j++) {
      x = ar[i][j];
      x--;
      col[x].insert(i);
      row[i].insert(x);
    }
  }
  vector<int> res;
  set<int> ones;
  for (int i = 0; i < n; i++)
    if ((int)row[i].size() == 1) ones.insert(i);
  while (!ones.empty()) {
    int i = *ones.begin();
    res.push_back(i);
    ones.erase(ones.begin());
    int j = *row[i].begin();
    vector<pair<int, int>> to_erase;
    for (int q : col[j]) {
      if (q == i) continue;
      to_erase.emplace_back(q, j);
      if ((int)row[q].size() == 2) ones.insert(q);
      if ((int)row[q].size() == 1) ones.erase(q);
    }
    for (auto [q, p] : to_erase) row[q].erase(p), col[p].erase(q);
  }
  vector<vector<pair<int, int>>> g(m);
  for (int i = 0; i < n; i++) {
    if ((int)row[i].size() != 2) continue;
    int u = *row[i].begin();
    int v = *(--row[i].end());
    g[u].emplace_back(v, i);
    g[v].emplace_back(u, i);
  }
  vector<int> used(m);
  for (int s = 0; s < m; s++) {
    if (used[s]) continue;
    queue<int> q;
    q.push(s);
    used[s] = 1;
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (auto [to, i] : g[v]) {
        if (!used[to]) used[to] = 1, res.push_back(i), q.push(to);
      }
    }
  }
  sort(res.begin(), res.end());
  return res;
}
void gen(int& n, int& m, vector<vector<int>>& ar, mt19937& rnd) {
  const int MAXN = 100;
  n = rnd() % MAXN + 1;
  m = rnd() % MAXN + 1;
  ar.resize(n);
  for (int i = 0; i < n; i++) {
    int k = rnd() % min(2, m) + 1;
    if (k == 1) {
      ar[i].push_back(rnd() % m + 1);
    } else {
      int x, y;
      while (1) {
        x = rnd() % m + 1;
        y = rnd() % m + 1;
        if (x != y) break;
      }
      if (x > y) swap(x, y);
      ar[i] = {x, y};
    }
  }
  sort(ar.begin(), ar.end());
  ar.erase(unique(ar.begin(), ar.end()), ar.end());
  n = (int)ar.size();
}
void read(int& n, int& m, vector<vector<int>>& ar) {
  cin >> n >> m;
  ar.resize(n);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    ar[i].resize(k);
    for (int j = 0; j < k; j++) cin >> ar[i][j];
  }
}
void work() {
  int n, m;
  vector<vector<int>> ar;
  read(n, m, ar);
  vector<int> res = fast(n, m, ar);
  int pw = 1;
  for (int i = 0; i < (int)res.size(); i++) pw = (1ll * pw * 2) % mod;
  cout << pw << " " << (int)res.size() << "\n";
  for (int i : res) cout << i + 1 << " ";
  cout << "\n";
}
vector<int> slow(int n, int m, vector<vector<int>> ar) {
  const int X = 200;
  vector<bitset<X>> a(n);
  for (int i = 0; i < n; i++)
    for (int j : ar[i]) a[i][j - 1] = 1;
  vector<int> res, used(n);
  for (int j = 0; j < m; j++) {
    int q = 0;
    while (q < n && (used[q] || !a[q][j])) q++;
    if (q == n) continue;
    used[q] = 1;
    res.push_back(q);
    for (int i = 0; i < n; i++) {
      if (i == q) continue;
      if (a[i][j]) a[i] ^= a[q];
    }
  }
  return res;
}
void test() {
  mt19937 rnd(42);
  while (1) {
    int n, m;
    vector<vector<int>> ar;
    gen(n, m, ar, rnd);
    cout << n << " " << m << endl;
    for (int i = 0; i < n; i++) {
      cout << ar[i].size() << endl;
      for (int j : ar[i]) cout << j << " ";
      cout << endl;
    }
    vector<int> fs = fast(n, m, ar);
    vector<int> sl = slow(n, m, ar);
    if (fs.size() == sl.size()) {
      cout << "OK(" << fs.size() << ")" << endl;
    } else {
      cout << "WA\n";
      cout << "exp = ";
      for (auto x : sl) cout << x << " ";
      cout << "\n";
      cout << "fnd = ";
      for (auto x : fs) cout << x << " ";
      cout << "\n";
      break;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  work();
  return 0;
}
