import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.io.InputStream;

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

  static class TaskF {
    private static final ModArithmetic mod = new ModArithmetic();

    public final void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int m = in.nextInt();
      int[] idx1 = new int[m + 1];
      int[] idx2 = new int[m + 1];

      ArrayList<Integer> ans = new ArrayList<>();
      HashSet<Long> found = new HashSet<>();
      int[] last = new int[m + 1];
      Arrays.fill(last, -1);
      for (int i = 0; i < n; i++) {
        int size = in.nextInt();
        if (size == 1) {
          int b = in.nextInt();
          if (idx1[b] == 0) {
            idx1[b] = i + 1;
            last[b] = 0;
            ans.add(i + 1);
          }
        } else {
          int b1 = in.nextInt();
          int b2 = in.nextInt();
          if (b1 > b2) {
            int t = b1;
            b1 = b2;
            b2 = t;
          }
          while (last[b2] != -1 && !found.contains(hash(b1, b2))) {
            found.add(hash(b1, b2));
            b2 = last[b2];
            if (b1 > b2) {
              int t = b1;
              b1 = b2;
              b2 = t;
            }
          }
          //        out.println(b1 + " " + b2);
          if (b1 == 0 && b2 == 0) {
            continue;
          }
          if (b1 == 0) {
            if (idx1[b2] == 0) {
              idx1[b2] = i + 1;
              last[b2] = 0;
              ans.add(i + 1);
            }
            continue;
          }

          found.add(hash(b1, b2));
          ans.add(i + 1);
        }
      }

      //    for (int i = 0; i < n; i++) {
      //      int size = in.nextInt();
      //      if (size == 1) {
      //        int b = in.nextInt() - 1;
      //        if (idx1[b] == 0) {
      //          idx1[b] = i + 1;
      //        }
      //      } else {
      //        int b1 = in.nextInt() - 1;
      //        int b2 = in.nextInt() - 1;
      //        if (idx2[b1] == 0) {
      //          idx2[b1] = i + 1;
      //        }
      //        if (idx2[b2] == 0) {
      //          idx2[b2] = i + 1;
      //        }
      //      }
      //    }
      //
      //    boolean[] used = new boolean[n + 1];
      //    for (int i = 0; i < m; i++) {
      //      if (idx1[i] != 0) {
      //        ans.add(idx1[i]);
      //      } else if (idx2[i] != 0 && !used[idx2[i]]) {
      //        used[idx2[i]] = true;
      //        ans.add(idx2[i]);
      //      }
      //    }
      //    ans.sort(null);

      out.println(mod.pow(2, ans.size()) + " " + ans.size());
      for (int x : ans) {
        out.print(x + " ");
      }
      out.println();
    }

    private long hash(long b1, long b2) {
      return b2 << 32 | b1;
    }
  }

  static final class ModArithmetic {
    public static final int DEFAULT_MOD = 1_000_000_007;
    public final int m;
    public final boolean isPrime;

    public ModArithmetic() {
      this(DEFAULT_MOD, true);
    }

    public ModArithmetic(int mod) {
      this(mod, false);
    }

    public ModArithmetic(int mod, boolean isPrime) {
      if (mod <= 0) {
        throw new IllegalArgumentException("Modulo must be > 0");
      }
      this.m = mod;
      this.isPrime = isPrime;
    }

    public final int pow(long a, long b) {
      long res = 1;
      while (b > 0) {
        if ((b & 1) == 1) {
          res *= a;
          if (res >= m) {
            res %= m;
          }
        }
        b >>= 1;
        a *= a;
        if (a >= m) {
          a %= m;
        }
      }
      return (int) res;
    }

    public String toString() {
      return "ModArithmetic{" + "m=" + m + ", isPrime=" + isPrime + '}';
    }
  }

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

    public InputReader() {
      this.stream = System.in;
    }

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

    private int read() {
      if (this.numChars == -1) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return -1;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public final int nextInt() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {}

      byte sgn = 1;
      if (c == 45) { // 45 == '-'
        sgn = -1;
        c = this.read();
      }

      int res = 0;

      while (c >= 48 && c <= 57) { // 48 == '0', 57 == '9'
        res *= 10;
        res += c - 48; // 48 == '0'
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }

      throw new InputMismatchException();
    }

    private static boolean isSpaceChar(final int c) {
      return c == 32 || c == 10 || c == 13 || c == 9
          || c == -1; // 32 == ' ', 10 == '\n', 13 == '\r', 9 == '\t'
    }
  }
}
