#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return (b == 0LL ? a : gcd(b, a % b));
}
long double dist(long double x, long double arayikhalatyan, long double x2,
                 long double y2) {
  return sqrt((x - x2) * (x - x2) +
              (arayikhalatyan - y2) * (arayikhalatyan - y2));
}
long long int S(long long int a) { return (a * (a + 1LL)) / 2; }
mt19937 rnd(363542);
char vow[] = {'a', 'e', 'i', 'o', 'u'};
int dx[] = {0, -1, 0, 1, -1, -1, 1, 1, 0};
int dy[] = {-1, 0, 1, 0, -1, 1, -1, 1, 0};
const int N = 1e6 + 30;
const long long int mod = 1e9 + 7;
const long double pi = acos(-1);
const int T = 238;
const long double e = 1e-13;
long long int bp(long long int a, long long int b = mod - 2LL) {
  long long int ret = 1;
  while (b) {
    if (b & 1) ret *= a, ret %= mod;
    a *= a;
    a %= mod;
    b >>= 1;
  }
  return ret;
}
ostream& operator<<(ostream& c, pair<int, int> a) {
  c << a.first << " " << a.second;
  return c;
}
struct pt {
  long long int x, y;
  int ind;
  int bl;
  bool operator==(const pt& a) { return ind == a.ind; }
  bool operator<(const pt& b) {
    if (x == b.x) return y < b.y;
    return x < b.x;
  }
};
int n, m;
vector<int> a[N];
int p[N], sz[N];
long long int f[N], fm[N];
int gp(int x) {
  if (p[x] == x) return x;
  return p[x] = gp(p[x]);
}
long long int c(int n, int k) {
  long long int ret = f[n];
  ret *= fm[k];
  ret %= mod;
  ret *= fm[n - k];
  ret %= mod;
  return ret;
}
long long int sm(int a) {
  if (a < 2) return 1;
  long long int sum = 0;
  for (int i = 0; i <= a; i += 2) {
    sum += c(a, i);
    sum %= mod;
  }
  return sum;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  f[0] = 1;
  fm[0] = bp(f[0]);
  for (int i = 1; i <= m + 1; i++)
    f[i] = f[i - 1] * 1LL * (long long int)i, fm[i] = bp(f[i]);
  for (int i = 0; i <= m + 5; i++) p[i] = i;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    int x, y;
    cin >> x;
    if (k == 1)
      y = 0;
    else
      cin >> y;
    if (gp(x) == gp(y)) continue;
    p[gp(x)] = gp(y);
    a[i].push_back(y), a[i].push_back(x);
  }
  vector<int> pat;
  for (int i = 0; i < n; i++)
    if (a[i].size()) pat.push_back(i + 1);
  for (int i = 1; i <= m; i++) sz[gp(i)]++;
  long long int ans = bp(2, sz[gp(0)]);
  for (int i = 1; i <= m; i++) {
    if (gp(i) != i) continue;
    if (i == gp(0)) continue;
    ans *= sm(sz[i]), ans %= mod;
  }
  cout << ans << " ";
  cout << pat.size() << endl;
  for (auto p : pat) cout << p << " ";
  return 0;
}
