import java.util.*;
import java.io.*;
public class Goodbye2020F{
	public static void main(String[] main) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		PrintWriter out = new PrintWriter(System.out);
		int n = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());
		int[] indep = new int[m];
		HashMap<Integer, HashSet<Integer>> adj = new HashMap<Integer, HashSet<Integer>>();
		HashSet<Integer> badindex = new HashSet<Integer>();
		for(int i = 0; i < n; i++) {
			adj.put(i, new HashSet<Integer>());
		}
		int counter = 0;
		//HashMap<Num, HashSet<Integer>> con = new HashMap<Num, HashSet<Integer>>();
		HashMap<Integer, Num> rev = new HashMap<Integer,Num>();
		HashSet<Integer> indepV = new HashSet<Integer>();
		for(int i = 0; i < n; i++) {
			st = new StringTokenizer(br.readLine());
			int k = Integer.parseInt(st.nextToken());
			if(k == 1) {
				int x = Integer.parseInt(st.nextToken())-1;
				if(rev.keySet().contains(x)) {
					if(indepV.contains(rev.get(x).getV()))
						badindex.add(i+1);
					else
						indepV.add(rev.get(x).getV());
				}
				else {
					rev.put(x, new Num(counter));
					indepV.add(counter);
					counter++;
				}
			}
			else {
				int x1 = Integer.parseInt(st.nextToken())-1;
				int x2 = Integer.parseInt(st.nextToken())-1;
				adj.get(x1).add(x2);
				adj.get(x2).add(x1);
				if(rev.keySet().contains(x1)) {
					if(rev.keySet().contains(x2)) {
						if(rev.get(x1).getV() == rev.get(x2).getV())
							badindex.add(i+1);
						else
							rev.get(x2).setV(rev.get(x1).getV());
					}
					else {
						rev.put(x2, rev.get(x1));
					}
				}
				else {
					if(rev.keySet().contains(x2)) {
						rev.put(x1, rev.get(x2));
					}
					else {
						Num next = new Num(counter);
						rev.put(x1, next);
						rev.put(x2, next);
						counter++;
					}
				}
				if(indep[x1] > 0 && indep[x2] > 0)
					badindex.add(i+1);
				else if(indep[x1] > 0)
					indep[x2] = m+1;
				else if(indep[x2] > 0) {
					indep[x1] = m+1;
				}
			}
		}
		int[] freq = new int[counter];
		long ans = 1;
		int mod = 1000000007;
		for(int i = 0; i < m; i++) {
			if(indepV.contains(rev.get(i).getV()))
				ans = (2*ans)%mod;
			else
				freq[rev.get(i).getV()]++;
		}
		long[] pow = new long[60];
		pow[0] = 1;
		for(int i = 1; i < 60; i++) {
			pow[i] = 2*pow[i-1];
		}
		for(int i = 0; i < counter; i++) {
			if(freq[i] > 0)
				ans = (ans*pow[freq[i-1]])%mod;
		}
		out.println(ans + " " + (n - badindex.size()));
		StringJoiner sj = new StringJoiner(" ");
		for(int i = 1; i <= n; i++)
			if(!badindex.contains(i))
				sj.add(Integer.toString(i));
		out.println(sj);
		out.close();
	}
}
class Num{
	private int val;
	public Num(int a) {
		val = a;
	}
	public int getV() {
		return val;
	}
	public void setV(int a) {
		val = a;
	}
}