You may know that Euclid was a mathematician. Well, as it turns out, Morpheus knew it too. So when he wanted to play a mean trick on Euclid, he sent him an appropriate nightmare. 

In his bad dream Euclid has a set S of n m-dimensional vectors over the Z_2 field and can perform vector addition on them. In other words he has vectors with m coordinates, each one equal either 0 or 1. Vector addition is defined as follows: let u+v = w, then w_i = (u_i + v_i) mod 2. 

Euclid can sum any subset of S and archive another m-dimensional vector over Z_2. In particular, he can sum together an empty subset; in such a case, the resulting vector has all coordinates equal 0.

Let T be the set of all the vectors that can be written as a sum of some vectors from S. Now Euclid wonders the size of T and whether he can use only a subset S' of S to obtain all the vectors from T. As it is usually the case in such scenarios, he will not wake up until he figures this out. So far, things are looking rather grim for the philosopher. But there is hope, as he noticed that all vectors in S have at most 2 coordinates equal 1. 

Help Euclid and calculate |T|, the number of m-dimensional vectors over Z_2 that can be written as a sum of some vectors from S. As it can be quite large, calculate it modulo 10^9+7. You should also find S', the smallest such subset of S, that all vectors in T can be written as a sum of vectors from S'. In case there are multiple such sets with a minimal number of elements, output the lexicographically smallest one with respect to the order in which their elements are given in the input. 

Consider sets A and B such that |A| = |B|. Let a_1, a_2, ... a_{|A|} and b_1, b_2, ... b_{|B|} be increasing arrays of indices elements of A and B correspondingly. A is lexicographically smaller than B iff there exists such i that a_j = b_j for all j < i and a_i < b_i.

Input

In the first line of input, there are two integers n, m (1 ≤ n, m ≤ 5 ⋅ 10^5) denoting the number of vectors in S and the number of dimensions. 

Next n lines contain the description of the vectors in S. In each of them there is an integer k (1 ≤ k ≤ 2) and then follow k distinct integers x_1, ... x_k (1 ≤ x_i ≤ m). This encodes an m-dimensional vector having 1s on coordinates x_1, ... x_k and 0s on the rest of them.

Among the n vectors, no two are the same.

Output

In the first line, output two integers: remainder modulo 10^9+7 of |T| and |S'|. In the second line, output |S'| numbers, indices of the elements of S' in ascending order. The elements of S are numbered from 1 in the order they are given in the input.

Examples

Input


3 2
1 1
1 2
2 2 1


Output


4 2
1 2 


Input


2 3
2 1 3
2 1 2


Output


4 2
1 2 


Input


3 5
2 1 2
1 3
1 4


Output


8 3
1 2 3 

Note

In the first example we are given three vectors: 

  * 10 
  * 01 
  * 11 



It turns out that we can represent all vectors from our 2-dimensional space using these vectors: 

  * 00 is a sum of the empty subset of above vectors; 
  * 01 = 11 + 10, is a sum of the first and third vector; 
  * 10 = 10, is just the first vector; 
  * 11 = 10 + 01, is a sum of the first and the second vector. 



Hence, T = \{00, 01, 10, 11\}. We can choose any two of the three vectors from S and still be able to obtain all the vectors in T. In such a case, we choose the two vectors which appear first in the input. Since we cannot obtain all vectors in T using only a single vector from S, |S'| = 2 and S' = \{10, 01\} (indices 1 and 2), as set \{1, 2 \} is lexicographically the smallest. We can represent all vectors from T, using only vectors from S', as shown below: 

  * 00 is a sum of the empty subset; 
  * 01 = 01 is just the second vector; 
  * 10 = 10 is just the first vector; 
  * 11 = 10 + 01 is a sum of the first and the second vector. 
/*
    构造一个正交化的线性基
    实现完全正交 is impossible;
        退而求之局部正交,即crucial musk不能出现在其他向量中
    
    竟然要用并查集我日你先人(
*/

#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define pb push_back
const int ha = 1e9+7;

inline int add(int x,int y){ x+=y; return x>=ha?x-ha:x;}
inline void ADD(int &x,int y){ x+=y; if(x>=ha) x-=ha;}

inline int ksm(int x,int y){
    int an=1;
    for(;y;y>>=1,x=x*(ll)x%ha) if(y&1) an=an*(ll)x%ha;
    return an;
}

class liner_base{
public:
    int n,*e,*hd,*ne,*tl;
    char *ex;

    liner_base(int N) : n(N){
        e = new int [N+5];  
        hd = new int [N+5];  
        ne = new int [N+5];
        tl = new int [N+5];
        ex = new char [N+5];
        memset(hd,0,sizeof(int)*(N+3));
        memset(ne,0,sizeof(int)*(N+3));
        memset(tl,0,sizeof(int)*(N+3));
        memset(ex,0,sizeof(char)*(N+3));
        for(int i=0;i<=N;i++)  e[i] = i;
    }

    ~liner_base(){
        /*
        delete e;
        delete hd;
        delete ne;
        delete tl;
        delete ex;
        */
    }

    int gete(int x){ return e[x] == x ? x : (e[x] = gete(e[x]));}

    inline void add_to_list(int Element,int List){
        ne[Element] = hd[List];
        e[Element] = List;
        hd[List] = Element;
        if(!tl[List]) tl[List] = Element;
    }

    void delete_list(int List){
        for(int now = hd[List],NE;now;now = NE)
            NE = ne[now] , e[now] = now , ne[now] = 0;
        hd[List] = tl[List] = 0;
    }

    inline void alter_list(int List1,int List2){
        if(!hd[List1]) return;
        if(!hd[List2]) hd[List2] = hd[List1],tl[List2] = tl[List1];
        else ne[tl[List2]] = hd[List1],tl[List2] = tl[List1];

        hd[List1] = tl[List1] = 0;
    }

    inline void add(int x){ /*printf("add %d\n",x),*/ex[x] = 1,e[x] = x,delete_list(x);}

    inline void add(int x,int y){ /*printf("add %d %d\n",x,y),*/ex[x] = 1,alter_list(x,y),add_to_list(x,y);}

    inline bool insert(int x){
        if(ex[x] && gete(x) == x) return 0;
        if(ex[x]) add(gete(x));
        else add(x);

        return 1;
    }

    inline bool insert(int x,int y){
        if(x == y) return 0;
        if(ex[x] && (gete(x) == x)) return insert(y);
        else if(ex[x]) return insert(min(gete(x),y),max(gete(x),y));
        else if(ex[y] && gete(y) == y) return insert(x);
        else if(ex[y]) return insert(x,gete(y));
        else add(x,y);
        return 1;
    }

    inline void consistent_check(){
        int *color = new int [n+5];
        memset(color,0,sizeof(int)*(n+3));

        for(int i=1;i<=n;i++)
            for(int j=hd[i];j;j=ne[j]) color[j] = i;
        for(int i=1;i<=n;i++) if(ex[i] && !color[i]) color[i] = i;
        
        for(int i=1;i<=n;i++) if(ex[i] && color[i] != gete(i)) 
			printf("There is an unconsistent with node %d\ncolor is %d, but father is %d\n",i,color[i],gete(i));

    }

    inline void check(){
        for(int i=1;i<=n;i++) if(ex[i]) printf("%d : %d\n",i,gete(i));
    }
};

int main(){
//    freopen("data.in","r",stdin);
//    freopen("data.out","w",stdout);

    int n,m; scanf("%d%d",&n,&m);
    liner_base a(m);
    queue<int> q;
    for(int opt,X,Y,i=1;i<=n;i++){
        scanf("%d",&opt);
        if(opt==1){
            scanf("%d",&X);
            if(a.insert(X)) q.push(i);
        }
        else{
            scanf("%d%d",&X,&Y);
            if(a.insert(min(X,Y),max(X,Y))) q.push(i);
        }
    }

//    a.consistent_check();

    printf("%d %d\n",ksm(2,q.size()),(int)q.size());
    while(!q.empty()) printf("%d ",q.front()),q.pop();
//    a.check();

    return 0;
}
