# from __future__ import print_function,division
# range = xrange
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10**9)
from sys import stdin, stdout
from collections import defaultdict, Counter
M = 10**9+7

def main():
    n,m = [int(s) for s in input().split()]
    l = [[int(s) for s in input().split()] for  i in range(n)]
    ans = []
    vis = [0]*(m+1)
    for i in range(n):
        if vis[l[i][1]]==0:
            ans.append(i+1)
            vis[l[i][1]]=1
            if l[i][0]==2:
                vis[l[i][2]] = 1
        elif l[i][0]==2 and vis[l[i][2]]==0:
            ans.append(i+1)
            vis[l[i][2]]=1
        
    print(pow(2,len(ans)),len(ans))
    print(*ans)


if __name__== '__main__':
    main()