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