#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
const int inf = 2e9 + 7;
double eps = 1e-6;
const int mod = 1e9 + 7;
const int N = 5e5 + 10;
const double pi = acos(-1.0);
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long exgcd(long long a, long long b, long long& x, long long& y) {
  long long c;
  return !b ? (x = 1, y = 0, a)
            : (c = exgcd(b, a % b, y, x), y -= (a / b) * x, c);
}
long long INV(long long a) {
  long long x, y;
  exgcd(a, mod, x, y);
  x %= mod;
  if (x < 0) x += mod;
  return x;
}
struct Edge {
  int v, id;
};
vector<Edge> g[N];
int vis[N];
int key[N];
void dfs(int u) {
  vis[u] = 1;
  for (auto e : g[u])
    if (!vis[e.v]) dfs(e.v);
}
struct Edge2 {
  int u, v, id;
};
int f[N];
int find(int u) { return f[u] == u ? u : f[u] = find(f[u]); }
int cnt;
void dfs2(int u) {
  vis[u] = 1;
  cnt++;
  for (auto e : g[u])
    if (!vis[e.v]) dfs2(e.v);
}
int val[N];
bool ok[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<Edge2> E;
  for (int i = 1; i <= m; ++i) val[i] = inf;
  for (int i = 1; i <= n; ++i) {
    int k;
    cin >> k;
    if (k == 1) {
      int x;
      cin >> x;
      vis[i] = 1;
      key[i] = 1;
      val[x] = i;
      E.push_back({0, x, i});
    } else {
      int x, y;
      cin >> x >> y;
      g[x].push_back({y, i});
      g[y].push_back({x, i});
      E.push_back({x, y, i});
    }
  }
  for (int i = 1; i <= m; ++i)
    if (key[i]) dfs(i);
  long long ans1 = 0;
  for (int i = 1; i <= m; ++i) ans1 += vis[i];
  for (int i = 1; i <= m; ++i)
    if (!vis[i]) {
      cnt = 0;
      dfs2(i);
      ans1 += cnt - 1;
    }
  for (int i = 1; i <= m; ++i) f[i] = i;
  vector<int> res;
  for (auto i : E) {
    if (i.u) {
      int X = find(i.u), Y = find(i.v);
      if (X != Y && (val[X] > i.id || val[Y] > i.id)) {
        if (val[X] > val[Y]) swap(X, Y);
        f[Y] = X;
        res.push_back(i.id);
      }
      ok[i.u] = ok[i.v] = 1;
    } else {
      if (!ok[i.v]) {
        res.push_back(i.id);
      } else {
        int X = find(i.v);
        if (val[X] > i.id) {
          f[X] = i.v;
          res.push_back(i.id);
        }
      }
      ok[i.v] = 1;
    }
  }
  sort((res).begin(), (res).end());
  cout << power(2, ans1) << " ";
  cout << res.size() << "\n";
  for (auto i : res) cout << i << " ";
}
