#include <bits/stdc++.h>
using namespace std;
     
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
     
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<pair<long double, int> , null_type,less<pair<long double, int> >, rb_tree_tag,tree_order_statistics_node_update> 
    
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
     
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
     
const int inf = int(1e9);
const ll INF = ll(1e16);
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
 
ll bp(ll a, ll n, ll cm){
  ll r = 1;
  while(n){
    if(n & 1) r = r * a % cm;
    a = a * a % cm;
    n >>= 1;
  }
  return r; 
}
template<typename T_vector> // neal
void output_vector(const T_vector &v, bool add_one = false, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());
    
    for (int i = start; i < end; i++)
        cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
} 
const int N = 5e5 + 1;
int ok[N];
void solve(){
  int n, m;
  cin >> n >> m;
  vector<vector<int> > v;
  vector<int> cnt(m + 1);
  for(int i = 0; i < n; ++i){
    int k;
    cin >> k;
    vector<int> c(k);
    for(int j = 0; j < k; ++j){
      cin >> c[j];
      c[j] -= 1;
      cnt[c[j]]++;
    }
    v.pb(c);
  }  
  // 101
  // 110
  // 011
  //////
//  000
  // 001
  // 010
  // 011
  //110
  //111
  // 110
  // 101
  // 011
  // 1100
  // 0011
  // 1000
  // 101
  // 110
  // 011
  vector<int> out;
  for(int i = n - 1; i >= 0; --i){
    bool bad = 0;
    for(int x : v[i]){
      if(cnt[x] == 1) bad = 1;
    }
    if(sz(v[i]) == 1) bad = 1;
    if(bad) out.pb(i);
  }
  cout << bp(2, sz(out), mod) << ' ' << sz(out) << '\n';
  reverse(all(out));
  for(int x : out) cout << x + 1 << ' ';
    // 000

    // 0110
    
    // 1010

    // 1001
}
int main()
{
  // freopen("input.txt", "r", stdin)
  // freopen("output.txt", "w", stdout);
    Red;
    int T = 1;
    // cin >> T;
    for(int i = 1; i <= T; ++i){
      solve();
    }
    return 0;

    
}