N, M = map(int, input().split())
k = [0] * M
s = [0] * M
for i in range(M):
  l = [int(j) for j in input().split()]
  k[i], s[i] = l[0], l[1:]
p = [int(i) for i in range(M)]

res = 0
for bit in range(2**N):
  sw = [0] * N
  for i in range(N):
    sw[i] = (bit >> i) & 1
  are_shining = True
  for i in range(M):
    cnt_on = 0
    for j in range(k[i]):
      if sw[s[i][j]-1] == 1:
        cnt_on += 1
    if cnt_on % 2 != p[i]:
      are_shining = False
  if are_shining:
    res += 1

print(res)
