n,m = map(int, input().split())
s = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
  ans += 1
  for key,j in enumerate(s):
    on = 0
    for k in j[1:]:  
      if ((i >> (k-1)) & 1):
        on += 1
    if (on % 2) != p[key]:
      ans -= 1
      break
      
print(ans)