#from collections import defaultdict
from sys import stdout
import io
import os
MOD = 1000000007

tree = []

def base(a):
    a_list = []
    while tree[a] != -1:
        a_list.append(a)
        a = tree[a]
    for elem in a_list:
        tree[elem] = a
    return a

if __name__ == "__main__":
    # structs
    # input
    input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
    n, m = [int(x) for x in input().decode().split()]
    tree = [-1 for i in range(m+1)]
    used = []
    pairs = [[] for _ in range(m)]
    for i in range(n):
        line = [int(x) for x in input().decode().split()]
        if line[0] == 1:
            used.append(i + 1)
            tree[line[1] - 1] = m
        else:
            if line[1] < line[2]:
                a, b = line[1] - 1, line[2] - 1
            else:
                a, b = line[2] - 1, line[1] - 1
            pairs[a].append((b, i + 1))

    for edges in pairs:
        if len(edges) > 1:
            edges.sort(reverse=True)

    for i, edges in enumerate(pairs[::-1]):
        for edge in edges:
            #print(m - 1 - i, edge)
            a = base(m - 1 - i)
            b = base(edge[0])
            #print(a, b)
            if a != b:
                tree[b] = a
                used.append(edge[1])

    # count sizes
    bases = [base(i) for i in range(m)]
    cnts = {}
    for x in bases:
        if x not in cnts:
            cnts[x] = 1
        else:
            cnts[x] += 1
    score = 1
    for id, cnt in cnts.items():
        if id != m:
            cnt -= 1
        for j in range(cnt):
            score *= 2
            if score >= MOD:
                score %= MOD

    used.sort()

    stdout.write('{} {}\n'.format(score, len(used)))
    stdout.write(' '.join([str(x) for x in used]) + '\n')
