#include <bits/stdc++.h>
using namespace std;
int n, m;
set<int> v[500010];
vector<int> adj[500010];
vector<int> ans2;
void read() {
  scanf("%d %d", &n, &m);
  for (int i = 1, k; i <= n; ++i) {
    scanf("%d", &k);
    for (int j = 1, x; j <= k; ++j) {
      scanf("%d", &x);
      v[i].insert(x);
      adj[x].push_back(i);
    }
  }
}
void work() {
  int ans1 = 1;
  for (int i = 1; i <= n; ++i) {
    if (v[i].size() == 0u) continue;
    int x = *v[i].begin();
    int y = -1;
    if (v[i].size() == 2u) y = *v[i].rbegin();
    for (auto &u : adj[x]) {
      v[u].erase(x);
      if (y > 0) {
        if (v[u].count(y) > 0u)
          v[u].erase(y);
        else {
          v[u].insert(y);
          adj[y].push_back(u);
        }
      }
    }
    ans1 *= 2;
    if (ans1 >= 1000000007) ans1 -= 1000000007;
    ans2.push_back(i);
  }
  printf("%d %d\n", ans1, (int)ans2.size());
  for (auto &it : ans2) printf("%d ", it);
  printf("\n");
}
int main() {
  read();
  work();
  return 0;
}
