#include <bits/stdc++.h>
using namespace std;
int n, m;
set<int> ss[500005];
vector<int> ans;
vector<int> a[500005];
int ha[500005];
const long long mod = 1e9 + 7;
int main() {
  cin >> n >> m;
  for (int i = 1, x; i <= n; i++) {
    scanf("%d", &x);
    for (int j = 1, y; j <= x; j++) {
      scanf("%d", &y);
      a[i].push_back(y);
    }
    sort(a[i].begin(), a[i].end());
    for (int j = x - 1; j >= 0; j--) {
      int y = a[i][j];
      if (ss[y].size() == 0) {
        ans.push_back(i);
        for (int k = 0; k < a[i].size(); k++) ss[y].insert(a[i][k]);
        ha[y] = i;
        break;
      } else {
        int pre = ha[y];
        int now = 0, cur = 0;
        vector<int> nxt;
        while (now < a[pre].size() && cur < a[i].size()) {
          while (a[pre][now] < a[i][cur] && now < a[pre].size()) {
            now++;
            nxt.push_back(a[pre][now]);
          }
          if (now >= a[pre].size()) break;
          if (a[pre][now] > a[i][cur]) {
            nxt.push_back(a[i][cur]);
          }
          cur++;
        }
        a[i] = nxt;
      }
    }
  }
  long long sum = 1ll;
  for (int i = 1; i <= ans.size(); i++) sum = (sum * 2) % mod;
  printf("%I64d ", sum);
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
  return 0;
}
