#include <bits/stdc++.h>
using namespace std;
const int MaxN = 5e5 + 10;
pair<int, pair<int, int>> arr[MaxN];
bool bad[MaxN];
long long pow(long long a, long long b, long long m) {
  long long ans = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      ans *= a;
      ans %= m;
    }
    a *= a;
    a %= m;
    b >>= 1;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  map<int, int> ones;
  map<int, map<int, int>> twos;
  for (int i = 0; i < n; i++) {
    cin >> arr[i].first;
    if (arr[i].first == 1) {
      cin >> arr[i].second.first;
      ones[arr[i].second.first] = i;
    } else {
      cin >> arr[i].second.first >> arr[i].second.second;
      twos[arr[i].second.first][arr[i].second.second] = i;
    }
  }
  for (int k = 0; k < 2; k++) {
    for (int i = 0; i < n; ++i) {
      if (!bad[i] && arr[i].first == 2) {
        if (ones.count(arr[i].second.first) &&
            !bad[ones[arr[i].second.first]] &&
            ones.count(arr[i].second.second) &&
            !bad[ones[arr[i].second.second]]) {
          int m =
              max({ones[arr[i].second.first], ones[arr[i].second.second], i});
          bad[m] = true;
          if (arr[i].second.first == m) {
            ones.erase(arr[i].second.first);
          }
          if (arr[i].second.second == m) {
            ones.erase(arr[i].second.second);
          }
          if (i == m) {
            twos[arr[i].second.first].erase(arr[i].second.second);
          }
        }
      }
    }
    for (int i = 0; i < n; i++) {
      if (!bad[i] && arr[i].first == 1) {
        if (twos.count(arr[i].second.first)) {
          bool myself = false;
          for (auto a : twos[arr[i].second.first]) {
            if (bad[a.second]) continue;
            if (ones.count(a.first)) {
              int m = max({i, ones[a.first], a.second});
              if (i == m) {
                ones.erase(arr[i].second.first);
                myself = true;
                break;
              }
            }
          }
          if (myself)
            bad[i] = true;
          else {
            vector<int> remove;
            for (auto a : twos[arr[i].second.first]) {
              if (bad[a.second]) continue;
              if (ones.count(a.first)) {
                int m = max({i, ones[a.first], a.second});
                bad[m] = true;
                if (ones[a.first] == m) {
                  ones.erase(a.first);
                }
                if (a.second == m) {
                  remove.push_back(a.first);
                }
                if (i == m) {
                  ones.erase(arr[i].second.first);
                  break;
                }
              }
            }
            for (auto a : remove) {
              twos[arr[i].second.first].erase(a);
            }
          }
        }
      }
    }
    for (int i = 0; i < n; i++) {
      if (!bad[i] && arr[i].first == 2) {
        bool myself = false;
        for (auto a : twos[arr[i].second.first]) {
          if (a.first != arr[i].second.second && !bad[a.second]) {
            if (twos.count(arr[i].second.second) &&
                twos[arr[i].second.second].count(a.first)) {
              int m = max({i, twos[arr[i].second.second][a.first], a.second});
              if (m == twos[arr[i].second.second][a.first]) {
                twos[arr[i].second.second].erase(a.first);
              }
              if (m == a.second) {
                twos[arr[i].second.first].erase(a.first);
              }
              if (i == m) {
                myself = true;
                break;
              }
            }
          }
        }
        if (myself) {
          twos[arr[i].second.first].erase(arr[i].second.second);
          bad[i] = true;
        } else {
          for (auto a : twos[arr[i].second.first]) {
            if (a.first != arr[i].second.second && !bad[a.second]) {
              if (twos.count(arr[i].second.second) &&
                  twos[arr[i].second.second].count(a.first)) {
                int m = max({i, twos[arr[i].second.second][a.first], a.second});
                bad[m] = true;
                if (m == twos[arr[i].second.second][a.first]) {
                  twos[arr[i].second.second].erase(a.first);
                }
                if (m == a.second) {
                  twos[arr[i].second.first].erase(a.first);
                }
                if (i == m) {
                  break;
                }
              }
            }
          }
        }
      }
    }
  }
  long long count = 0;
  for (int i = 0; i < n; i++) {
    if (!bad[i]) {
      count++;
    }
  }
  long long mod = (long)1e9 + 7;
  long long p = pow(2, count, mod);
  cout << p << " " << count << "\n";
  for (int i = 0; i < n; i++) {
    if (!bad[i]) cout << i + 1 << " ";
  }
}
