N, M = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
# print(N, M)
# print(ks)
# print(p)

ans = 0

import itertools
for i in itertools.product([0,1], repeat=N):
  righted = 0
  for iter, j in enumerate(ks):
    cnt = 0
    for k in range(1,len(j)):
      cnt += i[k-1]
    if cnt % 2 == p[iter]:
      righted += 1
  if len(ks) == righted:
    ans += 1
    
print(ans)
