import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class f {
	public static void main(String[] args) {
		FastScanner scan=new FastScanner();
		PrintWriter out=new PrintWriter(System.out);
		
		int n=scan.nextInt(), m=scan.nextInt();
		int[] f=new int[m];
		
		StringBuilder list=new StringBuilder();
		int ct=0;
		
		for(int i=0;i<n;i++) {
			int k=scan.nextInt();
			if(k==1) {
				int u=scan.nextInt()-1;
				
				if(f[u]%2==1) {
					continue;
				}
				
				f[u]++;
				ct++;
				list.append((i+1));
				list.append(" ");
			}
			else {
				int u=scan.nextInt()-1, v=scan.nextInt()-1;
				
				if(f[u]%2==1&&f[v]%2==1) {
					continue;
				}
				
				f[u]++;
				f[v]++;
				ct++;
				list.append((i+1));
				list.append(" ");
			}
			
		}
		
		out.println(pow(2,ct)+" "+ct);
		out.println(list);
		out.close();
	}
	public static long pow(long b, long e) {
		if(e==0) return 1L;
		if(e==1) return b;
		
		if(e%2==0) {
			long temp=pow(b,e/2);
			return (temp*temp)%MOD;
		}
		return (b*pow(b,e-1)%MOD)%MOD;
	}
	static final int MOD=1_000_000_007;
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			try	{
				br = new BufferedReader(new InputStreamReader(System.in));
				st = new StringTokenizer(br.readLine());
			} catch (Exception e){e.printStackTrace();}
		}

		public String next() {
			if (st.hasMoreTokens())	return st.nextToken();
			try {st = new StringTokenizer(br.readLine());}
			catch (Exception e) {e.printStackTrace();}
			return st.nextToken();
		}

		public int nextInt() {return Integer.parseInt(next());}

		public long nextLong() {return Long.parseLong(next());}

		public double nextDouble() {return Double.parseDouble(next());}

		public String nextLine() {
			String line = "";
			if(st.hasMoreTokens()) line = st.nextToken();
			else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
			while(st.hasMoreTokens()) line += " "+st.nextToken();
			return line;
		}
	}
}