MOD=10**9+7
import sys
input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok)
def oneLineArrayPrint(arr):
    print(' '.join([str(x) for x in arr]))
def solveActual():
    singleBitsPresent=[False for _ in range(m)]
    sPrime=[]
    
    for i in range(n):
        if len(vS[i])==1:
            singleBitsPresent[vS[i][0]]=True
    for i in range(n):
        if len(vS[i])==1:
            sPrime.append(i+1) #so output 1-indexed
        else:
            if not (singleBitsPresent[vS[i][0]] and singleBitsPresent[vS[i][1]]):
                sPrime.append(i+1)
    TSize=pow(2,len(sPrime),MOD)
    print('{} {}'.format(TSize,len(sPrime)))
    oneLineArrayPrint(sPrime)

def solveNaiveTest():
    from itertools import permutations
    vectors=[[0 for _ in range(m)]]
    for v in vS:
        temp=[0 for _ in range(m)]
        for i in v:
            temp[i]=1
        vectors.append(temp)
    allP=set()
    for i in range(1,n+1):
        for p in permutations(vectors,i):
            temp=[0 for _ in range(m)]
            for v in p:
                for j in range(m):
                    temp[j]+=v[j]
                    temp[j]%=2
            allP.add(tuple(temp))
    print('T size:{}'.format(len(allP)))
    

n,m=[int(x) for x in input().split()]
vS=[] #0-indexed

for _ in range(n):
    xx=[int(x) for x in input().split()]
    #number of 1s, coordinates with 1s
    for i in range(1,len(xx)):
        xx[i]-=1 #0-index
    vS.append(xx[1:])
#solveNaiveTest()
solveActual()