from itertools import product
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int,input().split()))

sw = list(product([True, False], repeat=N))
ans = 0
for pat in sw:
  cnt = 0
  flag = True
  for i in range(1, M+1):
    for j in range(ks[i-1][0]):
      if pat[ks[i-1][j+1]-1]:
        cnt += 1
    if cnt % 2 != p[i-1]:
      flag = False
      break
  if flag:
    ans += 1
print(ans)