#include <bits/stdc++.h>
using namespace std;
void adde(vector<long long int> adj[], long long int u, long long int v) {
  adj[u].push_back(v);
  adj[v].push_back(u);
}
long long int modInverse(long long int a, long long int m) {
  long long int m0 = m;
  long long int y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long int q = a / m;
    long long int t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  long long int dp[n][2];
  for (long long int i = 0; i < n; i++) {
    dp[i][0] = -1;
    dp[i][1] = -1;
  }
  long long int bit[m + 1];
  for (long long int i = 0; i <= m; i++) bit[i] = 0;
  set<long long int> s;
  long long int cnt = 0;
  for (long long int i = 0; i < n; i++) {
    long long int k;
    cin >> k;
    for (long long int j = 0; j < k; j++) {
      cin >> dp[i][j];
      bit[dp[i][j]] = 1;
      if (k == 1) s.insert(i);
    }
    if (k == 2) cnt++;
  }
  for (auto i : s) bit[dp[i][0]] = 0;
  long long int gn[cnt], cg = 0;
  long long int vis[m + 1];
  for (long long int i = 0; i <= m; i++) vis[i] = -1;
  for (long long int i = 0; i < n; i++) {
    if (dp[i][1] != -1) {
      if (bit[dp[i][0]] != 0 || bit[dp[i][1]] != 0) {
        if (vis[dp[i][0]] == -1 && vis[dp[i][1]] == -1) {
          vis[dp[i][0]] = cg;
          vis[dp[i][1]] = cg;
          gn[cg] = cg;
          cg++;
          s.insert(i);
        } else if (vis[dp[i][0]] == -1) {
          vis[dp[i][0]] = vis[dp[i][1]];
          s.insert(i);
        } else if (vis[dp[i][1]] == -1) {
          vis[dp[i][1]] = vis[dp[i][0]];
          s.insert(i);
        } else {
          while (gn[vis[dp[i][0]]] != vis[dp[i][0]])
            vis[dp[i][0]] = gn[vis[dp[i][0]]];
          while (gn[vis[dp[i][1]]] != vis[dp[i][1]])
            vis[dp[i][1]] = gn[vis[dp[i][1]]];
          if (gn[vis[dp[i][0]]] != gn[vis[dp[i][1]]]) {
            gn[vis[dp[i][0]]] = min(gn[vis[dp[i][0]]], gn[vis[dp[i][1]]]);
            gn[vis[dp[i][1]]] = min(gn[vis[dp[i][0]]], gn[vis[dp[i][1]]]);
            s.insert(i);
          }
        }
      }
    }
  }
  long long int ans = 1;
  cnt = 0;
  while (cnt < s.size()) {
    ans *= 2;
    ans = ans % 1000000007;
    cnt++;
  }
  cout << ans << " " << s.size() << "\n";
  for (auto i : s) cout << i + 1 << " ";
  return 0;
}
