import java.util.*;
import java.io.*;

public class F {
    public static long MOD = 1000000007;
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        StringTokenizer st = new StringTokenizer(f.readLine());
        int m = Integer.parseInt(st.nextToken());
        int n = Integer.parseInt(st.nextToken());
        int[] degrees = new int[n+1];
        Edge[] edges = new Edge[m];
        StringBuilder outedges = new StringBuilder();
        int cnt = 0;
        for(int i = 0; i < m; i++){
            st = new StringTokenizer(f.readLine());
            int a = Integer.parseInt(st.nextToken());
            if(a == 1){
                int b = Integer.parseInt(st.nextToken());
                edges[i] = new Edge(b, b);
            }else{
                edges[i] = new Edge(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()));
            }
            if(degrees[edges[i].a] < 2 || degrees[edges[i].b] < 2){
                outedges.append((i+1) + " ");
                cnt++;
                degrees[edges[i].a]++;
                degrees[edges[i].b]++;
            }
        }
        long ans = 1;
        for(int i = 0; i < cnt; i++) ans = (ans*2)%MOD;
        out.println(ans + " " + cnt);
        out.println(outedges.toString().trim());

        out.close();
    }
    static class Edge{
        public int a;
        public int b;
        public Edge(int a, int b){
            this.a=a;
            this.b=b;
        }
    }
}
