#include <bits/stdc++.h>
using namespace std;
long long a[1000001], b[1000001];
vector<int> edge[500005];
int p[500005], self[500005], sz[500005];
int find(int node) {
  if (node == p[node]) {
    return node;
  }
  return p[node] = find(p[node]);
}
bool Self(int k) {
  int x = find(k);
  if (self[x] == 1) {
    return 1;
  }
  return 0;
}
bool union_find(int node, int par) {
  int xx = find(node);
  int yy = find(par);
  if (xx == yy) return 1;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<int> answer;
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int k;
    cin >> k;
    edge[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> edge[i][j];
    }
  }
  long long ans = 1;
  for (int i = 1; i <= m; i++) {
    p[i] = i;
  }
  for (int i = 1; i <= n; i++) {
    if (edge[i].size() == 0) continue;
    if (edge[i].size() == 1) {
      if (!Self(edge[i][0])) {
        long long res = 1, x = 2, y = (long long)(i - 1);
        while (y > 0) {
          if (y & 1) {
            res = res * x;
            res %= 1000000007;
          }
          y = y / 2;
          x = x * x;
          x %= 1000000007;
        }
        ans += res;
        ans %= 1000000007;
        answer.push_back(i);
      }
      self[find(edge[i][0])] = 1;
    } else {
      if (Self(edge[i][0]) == 1 && Self(edge[i][1]) == 1) continue;
      if (union_find(edge[i][0], edge[i][1]) == 0) {
        int xx = find(edge[i][0]);
        int yy = find(edge[i][1]);
        if (self[xx] == 1 || self[yy] == 1) {
          self[xx] = 1;
        }
        p[yy] = xx;
        long long res = 1, x = 2, y = (long long)(i - 1);
        while (y > 0) {
          if (y & 1) {
            res = res * x;
            res %= 1000000007;
          }
          y = y >> 1;
          x = x * x;
          x %= 1000000007;
        }
        ans += res;
        ans %= 1000000007;
        answer.push_back(i);
      }
    }
  }
  cout << ans << ' ';
  cout << answer.size() << '\n';
  for (int i = 0; i < answer.size(); i++) {
    cout << answer[i] << ' ';
  }
}
