import sys
input = sys.stdin.readline
N, M = map(int, input().split())
mod = 10 ** 9 + 7

base = [0] * (M + 1)
e = [[] for _ in range(M + 1)]
res = []
for i in range(1, N + 1):
  #print(base, e)
  a = list(map(int, input().split()))
  if a[0] == 1:
    if base[a[1]] == -1: continue
    base[a[1]] = -1
    res.append(i)
    s = [a[1]]
    while len(s):
      x = s.pop()
      for y in e[x]:
        if base[y] == -1: continue
        base[y] = -1
        s.append(y)
  else:
    ok = 0
    s = []
    for x in a[1: ]:
      if base[x] != -1:
        ok += 1
        s.append(x)
    if ok == 0: continue
    if ok == 1:
      res.append(i)
      while len(s):
        x = s.pop()
        for y in e[x]:
          if base[y] == -1: continue
          base[y] = -1
          s.append(y)
    if ok == 2:
      res.append(i)
      e[a[1]].append(a[2])
      e[a[2]].append(a[1])
print(pow(2, len(res), mod), len(res))
print(*res)