import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Map.Entry;

import java.util.Random;
import java.util.TreeSet;

public final class CF_2020_GoodBye_Fb
{


	static boolean verb=true;
	static void log(Object X){if (verb) System.err.println(X);}
	static void log(Object[] X){if (verb) {for (Object U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");System.err.println("");}}
	static void logWln(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");}}
	static void log(int[] X,int L){if (verb) {for (int i=0;i<L;i++) System.err.print(X[i]+" ");System.err.println("");}}
	static void log(long[] X){if (verb) {for (long U:X) System.err.print(U+" ");System.err.println("");}}

	static void logWln(Object X){if (verb) System.err.print(X);}
	static void info(Object o){	System.out.println(o);}
	static void output(Object o){outputWln(""+o+"\n");	}
	static void outputFlush(Object o){try {out.write(""+ o+"\n");out.flush();} catch (Exception e) {}}
	static void outputWln(Object o){try {out.write(""+ o);} catch (Exception e) {}}


	static void logBin(int[] tm) {for (int x:tm) logWln(bin(8,x)+" ");log("");}

	static String bin(int L,int x) {
		String s=Integer.toBinaryString(x);
		while (s.length()<L) s="0"+s;
		return s;
	}

	static long powerMod(long b,long e,long m){
		long x=1;
		while (e>0) {
			if (e%2==1)
				x=(b*x)%m;
			b=(b*b)%m;
			e=e/2;
		}
		return x; 
	}


	//greater value, smaller rank
	static class Composite implements Comparable<Composite>{
		int a;
		int b;
		int idx;

		public int compareTo(Composite X) {
			if (a!=X.a)
				return a-X.a;
			if (b!=X.b)
				return b-X.b;
			return idx-X.idx;
		}

		public Composite(int a, int b, int idx) {
			this.a = a;
			this.b = b;
			this.idx = idx;
		}



	}


	static class BIT {

		long[] tree;
		int N;

		BIT(int N){
			tree=new long[N+1];
			this.N=N;
		}

		void add(int idx,int val){
			idx++;
			while (idx<=N){
				tree[idx]+=val;
				idx+=idx & (-idx);
			}
		}
		long read(int idx){
			idx++;
			long sum=0;
			while (idx>0){
				sum+=tree[idx];
				idx-=idx & (-idx);
			}
			return sum;
		}

	}

	static long mod=1000000007;



	// Global vars
	static BufferedWriter out;
	static InputReader reader;

	static int[][] dd={{-1,0},{0,1},{1,0},{0,-1}};

	static int CX=26;






	static void process() throws Exception {

		out = new BufferedWriter(new OutputStreamWriter(System.out));
		reader = new InputReader(System.in);

		log("hello");

		int n=reader.readInt();
		int m=reader.readInt();
		TreeSet<Integer>[] vec=new TreeSet[n];

		int cnt=0;
		int[] ref=new int[Math.max(n,m)+1];
		Arrays.fill(ref, -1);
		StringBuffer ans=new StringBuffer();
		long val=1;


		Composite[] ar=new Composite[n];

		for (int i=0;i<n;i++) {

			int k=reader.readInt();
			vec[i]=new TreeSet<Integer>();
			int a=reader.readInt();

			vec[i].add(a);
			int b=n+1;
			if (k==2) {
				b=reader.readInt();
				vec[i].add(b);
			}
			ar[i]=new Composite(a,b,i);

		}

		PriorityQueue<Composite> pq=new PriorityQueue<Composite>();
		for (Composite X:ar)
			pq.add(X);
		while (pq.size()>0) {
			Composite X=pq.poll();
			int i=X.idx;
			int z=vec[i].first();
			//log("processing:"+vec[i]);
			if (ref[z]!=-1) {
				int j=ref[z];
				for (int x:vec[j]) {
					if (vec[i].contains(x)) {
						vec[i].remove(x);
					} else
						vec[i].add(x);
				}
				if (vec[i].size()>0) {
					// reprocess
					pq.add(X);
				}
			} else {
				ref[z]=i;
				ans.append((i+1)+" ");
				cnt++;
				val*=2;
				if (val>=mod)
					val%=mod;

			}

		}
		/*
		for (int i=0;i<n;i++) {
			log(vec[i]);
		}
		*/

		output(val+" "+cnt);
		output(ans.toString());


		try {
			out.close();
		} catch (Exception Ex) {
		}

	}




	public static void main(String[] args) throws Exception {
		process();

	}

	static final class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int read() throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read(buf);
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar++];
		}

		public final String readString() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final String readString(int L) throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder(L);
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final int readInt() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		public final long readLong() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}

}