import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskF solver = new TaskF();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskF {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            final int MOD = (int) (1e9 + 7);
            int n = in.nextInt();
            int m = in.nextInt();
            int[] ans = new int[m];
            int ansSize = 0;
            boolean[] inBasis = new boolean[m];
            List<Integer>[] staging = new List[m];
            for (int i = 0; i < m; i++) {
                staging[i] = new ArrayList<>();
            }
            for (int i = 0; i < n; i++) {
                int k = in.nextInt();
                int[] v = new int[2];
                int numInBasis = 0;
                int added = -1;
                for (int j = 0; j < k; j++) {
                    v[j] = in.nextInt() - 1;
                    if (inBasis[v[j]]) {
                        ++numInBasis;
                    }
                }
                if (k == 1) {
                    if (numInBasis == 0) {
                        inBasis[v[0]] = true;
                        ans[ansSize++] = i;
                        added = v[0];
                    }
                } else {
                    if (numInBasis == 1) {
                        for (int j = 0; j < 2; j++) {
                            if (!inBasis[v[j]]) {
                                inBasis[v[j]] = true;
                                ans[ansSize++] = i;
                                added = v[j];
                            }
                        }
                    }
                    if (numInBasis == 0) {
                        ans[ansSize++] = i;
                        staging[v[0]].add(v[1]);
                        staging[v[1]].add(v[0]);
                    }
                }
                if (added >= 0) {
                    for (int x : staging[added]) {
                        if (!inBasis[x]) {
                            inBasis[x] = true;
                        }
                    }
                }
            }

            int p2 = 1;
            for (int i = 0; i < ansSize; i++) {
                p2 += p2;
                if (p2 >= MOD) {
                    p2 -= MOD;
                }
            }
            out.println(p2 + " " + ansSize);
            for (int i = 0; i < ansSize; i++) {
                if (i > 0) {
                    out.print(" ");
                }
                out.print(ans[i] + 1);
            }
            out.println();
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}

