#include <bits/stdc++.h>
using namespace std;
const int N = 500110;
const long long P = 1e9 + 7;
int n, k, m;
int fa[N], in1[N], vis[N];
int fd(int w) {
  if (fa[w] == w) return w;
  return fa[w] = fd(fa[w]);
}
long long qpow(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % P;
    a = (a * a) % P;
    b >>= 1;
  }
  return ans;
}
vector<int> ans, G[N];
vector<pair<int, int> > bs1;
vector<int> vv;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = (1); i <= (m); ++i) fa[i] = i;
  int hv1 = 0;
  function<void(int, int)> dfs = [&](int u, int pa) -> void {
    hv1 = min(in1[u], hv1);
    vis[u] = 1;
    for (int v : G[u])
      if (v != pa) {
        dfs(v, u);
      }
    G[u].clear();
    return;
  };
  for (int i = (1); i <= (n); ++i) {
    cin >> k;
    int x;
    vv.clear();
    for (int j = (1); j <= (k); ++j) cin >> x, vv.push_back(x);
    if (k == 1) {
      in1[x] = i;
      if (!vis[x]) {
        hv1 = m + 1;
        dfs(x, 0);
        ans.push_back(i);
      }
    } else {
      if (fd(vv[0]) != fd(vv[1])) {
        if (vis[vv[0]] && vis[vv[1]])
          ;
        else if (vis[vv[0]])
          vis[vv[1]] = 1, ans.push_back(i);
        else if (vis[vv[1]])
          vis[vv[0]] = 1, ans.push_back(i);
        else {
          fa[fd(vv[0])] = fd(vv[1]);
          ans.push_back(i);
          G[vv[0]].push_back(vv[1]);
          G[vv[1]].push_back(vv[0]);
        }
      }
    }
  }
  int ww = ans.size();
  cout << qpow(2, ww) << " " << ww << "\n";
  for (int &w : ans) cout << w << " ";
  cout << "\n";
}
