n, m = map(int, input().split())
lamps = [list(map(lambda x:int(x)-1, input().split()))[1:] for _ in range(m)]
p = [int(i) for i in range(m)]
ans = 0

for i in range(1 << n):
   for r in range(m):
      on_sum = 0
      for j in range(n):
         if i >> j & 1 and j in lamps[r]:
            on_sum += 1
      if (on_sum % 2 != p[r]):
         break
   else:
      ans += 1

print()
print(ans)
