N,M = map(int,input().split())
KS = [[int(x) for x in input().split()] for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for i in range(2**N):
  switch_pattern = bin(i)[2:].zfill(N)
  succes = 1
  for j in range(M):
    switch_on = 0
    for k in KS[j]:
      if switch_pattern[k-1] == '1':
        switch_on += 1
    if switch_on % 2 != P[j]:
      succes = 0
      break
  if succes == 1:
      ans += 1
print(ans)