N, M = map(int, input().split())
bi_N = [i+1 for i in range(2**N-1)]
ans = 0
l = []
for i in range(M):
  l.append(list(map(int, input().split())))
p = list(map(int, input().split()))
for i in bi_N[::-1]:
  a = format(i,'b')
  a = str(format(a, '0>10'))
  bi_a = [a[i] for i in range(10)]
  for z, (j, k) in enumerate(zip(l,p)):
    x = 0
    o = j[0]
    for y in range(o)[1:]:
      x += int(bi_a[-j[y]])
    if x%2 != k:
      break
    if z == M-1:
      ans += 1
print(ans)