#include <bits/stdc++.h>
using namespace std;
struct DisjointSet {
  vector<int> f, sz;
  DisjointSet(int size) {
    f.resize(size);
    sz.resize(size);
    for (int i = 0; i < size; i++) {
      f[i] = i;
      sz[i] = i;
    }
  }
  int father(int src) {
    if (src == f[src]) return src;
    return f[src] = father(f[src]);
  }
  bool unite(int a, int b) {
    int fa = father(a), fb = father(b);
    if (sz[fa] < sz[fb]) swap(fa, fb);
    if (fa == fb) return false;
    f[fb] = fa;
    sz[fa] = max(sz[fa], sz[fb] + 1);
    return true;
  }
};
const int sz = 5e5;
int n, m;
bitset<sz> unit, tmp;
vector<pair<pair<int, int>, int>> v;
vector<pair<int, int>> adj[sz];
bitset<sz> used;
void input() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x == 1) {
      int pos;
      cin >> pos;
      pos--;
      v.push_back({{pos, -1}, i});
    } else {
      int a, b;
      cin >> a >> b;
      v.push_back({{min(a, b) - 1, max(a, b) - 1}, i});
    }
  }
  sort(v.begin(), v.end());
}
void dfs(int src) {
  unit[src] = 1;
  for (pair<int, int> x : adj[src]) {
    if (!unit[x.first]) {
      used[x.second] = 1;
      dfs(x.first);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  input();
  DisjointSet dsu(n);
  for (auto x : v) {
    int a = x.first.first, b = x.first.second, i = x.second;
    if (b == -1) {
      if (!unit[a]) {
        used[i] = 1;
        dfs(a);
      }
    } else {
      if (unit[a] && unit[b])
        continue;
      else if (unit[a] ^ unit[b]) {
        used[i] = 1;
        if (!unit[a])
          dfs(a);
        else
          dfs(b);
      } else {
        adj[a].push_back({b, i});
        adj[b].push_back({a, i});
        if (!dsu.unite(a, b)) {
          dfs(a);
          used[i] = 1;
        }
      }
    }
  }
  long long x = 1, uc = used.count();
  for (int i = 0; i < uc; i++) {
    x <<= 1;
    x %= ((long long)(1e9 + 7));
  }
  cout << x << ' ' << uc << '\n';
  for (int i = 0; i < n; i++) {
    if (used[i]) cout << i + 1 << ' ';
  }
  return 0;
}
