import sys
input = sys.stdin.readline
n,m = [int(i) for i in input().split()]
k = []
for i in range(m):
  array = [int(i) for i in input().split()]
  k.append(array)

p = [int(i) for i in input().split()]
ans = 0
chk = 0

for i in range(2**n):
  r = format(i,'b')
  r = r.zfill(n)[::-1]
  for j in range(m):
    for l in range(1,k[j][0]+1):
      chk += int(r[k[j][l]-1])
    if chk % 2 != p[j]:
      chk = 0
      break
    if j == m-1:
      #print(r,chk)
      ans += 1
      chk = 0
  
print(ans)