#include <bits/stdc++.h>
using namespace std;
int dsu[500100];
int get(int x) {
  if (dsu[x] == x) return x;
  return dsu[x] = get(dsu[x]);
}
void unite(int a, int b) {
  a = get(a);
  b = get(b);
  if (rand() % 2) swap(a, b);
  dsu[a] = b;
}
vector<pair<int, int>> g[500100];
bool taken[500100];
bool dead[500100];
bool dfs(int v, int p) {
  for (pair<int, int> e : g[v]) {
    int u = e.first;
    if (u != p) {
      if (dfs(u, v)) {
        dead[e.second] = true;
      }
    }
  }
  return taken[v];
}
int main() {
  for (int i = 0; i < 500100; i++) {
    dsu[i] = i;
  }
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  const long long mod = 1000000000 + 7;
  long long ans = 1;
  vector<int> t;
  vector<vector<int>> s;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    vector<int> tmp(k);
    for (int j = 0; j < k; j++) {
      cin >> tmp[j];
    }
    s.push_back(tmp);
  }
  for (int i = 0; i < n; i++) {
    if (s[i].size() == 1) {
      taken[s[i][0]] = true;
      t.push_back(i);
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i].size() == 2) {
      int a = s[i][0];
      int b = s[i][1];
      if (get(a) == get(b)) {
        continue;
      }
      unite(a, b);
      g[a].push_back({b, i});
      g[b].push_back({a, i});
    }
  }
  for (int i = 1; i <= m; i++) {
    if (taken[i]) {
      dfs(i, -1);
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i].size() == 2) {
      int a = s[i][0];
      int b = s[i][1];
      if (!dead[i]) {
        ans *= 2;
        ans %= mod;
        t.push_back(i);
        if (taken[a]) {
          ans *= 2;
          ans %= mod;
        }
        if (taken[b]) {
          ans *= 2;
          ans %= mod;
        }
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    if (taken[i] && g[i].size() <= 1) {
      ans *= 2;
      ans %= mod;
    }
  }
  sort(t.begin(), t.end());
  cout << ans << " " << t.size() << "\n";
  for (int x : t) {
    cout << x + 1 << " ";
  }
}
