n,m=map(int,input().split())
x = [list(map(int,input().split())) for i in range(m)]
eo = list(map(int,input().split()))
ans = 0
for i in range(2**n):
  sw = [0]*n
  binstr = format(i,"b").zfill(n)
  for j in range(n):
    if binstr[j] == "1":
      sw[j] = 1
  light = 0
  for k,y in enumerate(x):
    numsw = 0
    for z in range(1,y[0]+1):
      if sw[z-1] == 1:
        numsw += 1  
    if numsw%2 == eo[k]:
      light += 1
  if light == m:
    ans += 1
print(ans)