import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class F {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        // Scanner scan = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); 
        // int n = Integer.parseInt(bf.readLine());
        StringTokenizer st = new StringTokenizer(bf.readLine());
        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
        int mod = 1000000007;
        
        // -2 means empty
        // -1 means it can be toggled
        int[] partner = new int[m];
        int[][] vectors = new int[n][3];
        Arrays.fill(partner, -2);
        int ans = 0;
        StringBuilder indices = new StringBuilder();
        ArrayList<Integer> ind = new ArrayList<Integer>();
        for(int i=0; i<n; i++) {
          st = new StringTokenizer(bf.readLine());
          int type = Integer.parseInt(st.nextToken());
          if(type == 1) {
            int val = Integer.parseInt(st.nextToken()) - 1;
            if(partner[val] != -1) {
              ind.add(i);
              ans += 1;
            }
            partner[val] = -1; 
            vectors[i][0] = 1;
            vectors[i][1] = val;
          }
          else {
            int val1 = Integer.parseInt(st.nextToken()) - 1;
            int val2 = Integer.parseInt(st.nextToken()) - 1;
            vectors[i][0] = 2;
            vectors[i][1] = val1;
            vectors[i][2] = val2;
            if((partner[val1] == val2 && partner[val2] == val1) || (partner[val1] == -2 && partner[val2] == -2)) {
             
              if((partner[val1] == -2 && partner[val2] == -2)) {
                ind.add(i);
                ans += 1;
              }
               partner[val1] = val2;
              partner[val2] = val1;
            }
            else {
              if(partner[val1] != -1 || partner[val2] != -1) {
                ind.add(i);
                ans += 1;
              }
              partner[val1] = -1; 
              partner[val2] = -1; 
            }
          }
          //System.out.println(ans);
        }
       
        int pairs = 0;
        /*
        int[] finalvector = new int[m];
        for(int i=0; i<m; i++) {
          if(partner[i] == -1) {
           // ans += 1;
            finalvector[i] = -2;
          }
          else if(partner[i] >= 0 && partner[partner[i]] == i) {
            pairs += 1;
            finalvector[i] = -3;
            ind.add(i);
          }

        }
        ans += pairs/2;*/
        
       Collections.sort(ind);
       for(int i=0; i<ind.size(); i++) {
         indices.append((ind.get(i)+1)+" ");
       }
        
        out.println(exp(2, ans, mod) + " " + ans);
        out.println(indices.toString());
        // int n = scan.nextInt();
        
        out.close(); System.exit(0);
    }
    // Exponentation
    public static int exp(int base, int e, int mod) {
      if(e == 0) return 1;
      if(e == 1) return base;
      int val = exp(base, e/2, mod);
      int ans = (int)(1L*val*val % mod);
      if(e % 2 == 1)
        ans = (int)(1L*ans*base % mod);
      return ans;
    }
}

        
        