from itertools import product
n,m = map(int,input().split())
l = [list(map(int,input().split()))[1:] for _ in range(m)]
p = list(map(int,input().split()))
s = 0
a = 0
for i in product([0,1],repeat=n):
  for j in l:
    for k in j:
  #    print(i,j,k)
      a += i[k-1]
 #   print(a,p[l.index(j)])
    if a%2!=p[l.index(j)]:
      break
    a =0
  else:
    s += 1
print(s)