#include <bits/stdc++.h>
using namespace std;
vector<int> v[500005];
unordered_map<int, int> mp;
vector<int> ans;
long long cnt = 1, mod = 1000000007;
int main() {
  int n, m, x = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int t, tt;
    scanf("%d", &t);
    for (int j = 1; j <= t; j++) {
      scanf("%d", &tt);
      if (!mp[tt]) mp[tt] = ++x;
      v[i].push_back(mp[tt]);
    }
    sort(v[i].begin(), v[i].end());
  }
  for (int i = 1; i <= n; i++) {
    int f = 0;
    for (int j = 0; j < v[i].size(); j++)
      if (v[i][j] >= i) f = 1;
    if (f) cnt = cnt * 2 % mod, ans.push_back(i);
  }
  printf("%lld %d\n", cnt, ans.size());
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
  return 0;
}
