import java.util.*;
import java.io.*;
import java.math.*;

public class cf {
	static PrintWriter pw = new PrintWriter(System.out);

	public static void main(String[] args) throws IOException, InterruptedException {
		Scanner sc = new Scanner(System.in);
		int t = 1;
//		t = sc.nextInt();
		while (t-- > 0) {
			int n = sc.nextInt(), m = sc.nextInt();
			HashMap<Integer, Integer> hm = new HashMap<>();
			TreeSet<Integer> ans = new TreeSet<>();
			TreeMap<pair, Integer> tm = new TreeMap<>();
			for (int i = 0; i < n; i++) {
				if (sc.nextInt() == 1) {
					int a = sc.nextInt();
					if (!hm.containsKey(a)) {
						ans.add(i);
						hm.put(a, i);
					}
				} else {
					pair p = new pair(sc.nextInt(), sc.nextInt());
					if (!tm.containsKey(p))
						tm.put(p, i);
				}
			}
//			int c = 0;
			while (!tm.isEmpty()) {
				pair p = tm.firstKey();
				int idx = tm.get(p);
				if (!hm.containsKey(p.x) && !hm.containsKey(p.y)) {
//					c++;
					ans.add(idx);
					hm.put(p.x, idx);
					hm.put(p.y, idx);
				} else if (!hm.containsKey(p.x)) {
					ans.add(idx);
					hm.put(p.x, idx);
				} else if (!hm.containsKey(p.y)) {
					ans.add(idx);
					hm.put(p.y, idx);
				} else {
					int i1 = hm.get(p.x), i2 = hm.get(p.y);
					if (idx < i1 && idx < i2) {
						if (i1 > i2) {
							ans.remove(i1);
							ans.add(idx);
							hm.put(p.x, idx);
						} else {
							ans.remove(i2);
							ans.add(idx);
							hm.put(p.y, idx);
						}
					} else if (idx < i1) {
						ans.remove(i1);
						ans.add(idx);
						hm.put(p.x, idx);
					} else if (idx < i2) {
						ans.remove(i2);
						ans.add(idx);
						hm.put(p.y, idx);
					}
				}
				tm.pollFirstEntry();
			}
//			pw.println(ans);
			pw.println(pow(2, ans.size(), (int) 1e9 + 7) + " " + ans.size());
			while (!ans.isEmpty()) {
				pw.print(ans.pollFirst() + 1 + " ");
			}
		}
		pw.close();
	}

	static long pow(long a, long e, long mod) {
		a %= mod;
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}

	public static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public boolean equals(Object o) {
			if (o instanceof pair) {
				pair p = (pair) o;
				return p.x == x && p.y == y;
			}
			return false;
		}

		public int hashCode() {
			return new Double(x).hashCode() * 31 + new Double(y).hashCode();
		}

		public int compareTo(pair other) {
			if (this.x == other.x) {
				return Long.compare(this.y, other.y);
			}
			return Long.compare(this.x, other.x);
		}
	}

	public static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public String toString() {
			return x + " " + y + " " + z;
		}

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				if (this.y == other.y)
					return this.z - other.z;
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public long[] nextlongArray(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public Long[] nextLongArray(int n) throws IOException {
			Long[] a = new Long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public Integer[] nextIntegerArray(int n) throws IOException {
			Integer[] a = new Integer[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}