n,m = [int(j) for j in input().split()]
vis = [0 for i in range(m)]
ans = []
for i in range(n):
    l = [int(j) for j in input().split()]
    if len(l)==2:
        if vis[l[1]-1]==0:
            ans.append(i+1)
            vis[l[1]-1]=1
    else:
        if vis[l[1]-1]==0 and vis[l[2]-1]==0:
            ans.append(i+1)
            vis[l[1]-1]=1
            vis[l[2]-1]=1
        elif vis[l[1]-1]==0 and vis[l[2]-1]==1:
            ans.append(i+1)
            vis[l[1]-1]=1
        elif vis[l[1]-1]==1 and vis[l[2]-1]==0:
            ans.append(i+1)
            vis[l[2]-1]=1
k = len(ans)
if k==1:
    print(1,1)
    print(*ans)
else:
    print(pow(2,k,7+10**9),k)
    print(*ans)
