import java.util.*;
import java.io.*;
public class Goodbye2020F{
	static int mod = 1000000007;
	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());
		HashSet<Integer> badindex = new HashSet<Integer>();
		int counter = 0;
		Layer firstindep = null;
		HashMap<Integer, Layer> rev = new HashMap<Integer, Layer>();
		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(firstindep.getV() == rev.get(x).getV())
						badindex.add(i+1);
					else
						rev.put(x, firstindep);
				}
				else {
					if(firstindep == null) {
						rev.put(x, new Layer(new Num(counter)));
						counter++;
					}
					else {
						rev.put(x, firstindep);
					}
				}
				if(firstindep == null)
					firstindep = rev.get(x);
			}
			else {
				int x1 = Integer.parseInt(st.nextToken())-1;
				int x2 = Integer.parseInt(st.nextToken())-1;
				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).setN(rev.get(x1).getN());
					}
					else {
						rev.put(x2, rev.get(x1));
					}
				}
				else {
					if(rev.keySet().contains(x2)) {
						rev.put(x1, rev.get(x2));
					}
					else {
						Layer next = new Layer(new Num(counter));
						rev.put(x1, next);
						rev.put(x2, next);
						counter++;
					}
				}
			}
		}
		int S = n - badindex.size(); 
		long ans = pow(S);
		out.println(ans + " " + S);
		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();
	}
	public static long pow(int a) {
		if(a == 0)
			return 1;
		if(a%2 == 0) {
			long ans = pow(a/2);
			return (ans*ans)%mod;
		}
		else {
			long ans = pow(a/2);
			return(ans*ans*2)%mod;
		}
	}
}
class Num{
	private int val;
	public Num(int a) {
		val = a;
	}
	public int getV() {
		return val;
	}
	public void setV(int a) {
		val = a;
	}
}
class Layer{
	private Num n;
	public Layer(Num a) {
		n = a;
	}
	public int getV() {
		return n.getV();
	}
	public Num getN() {
		return n;
	}
	public void setN(Num a) {
		n = a;
	}
}