n,m = map(int,input().split())
L = [list(map(int,input().split()))[1:] for _ in range(m)]
P = list(map(int,input().split()))
ans = 0
for i in range(2 ** n):
  on = bin(i)[2:].zfill(n)
  for s,p in zip(L,P):
    if sum(int(on[sij-1]) for sij in s) % 2 != p:
      break
  else:
    ans += 1
print(ans)