N,M = map(int, input().split())
sbit = [0] * M
for i in range(M):
  l = list(map(int, input().split()))
  bit = 0
  for j in range(1, l[0]):
    bit += 1 << l[j + 1]
  sbit[i] =  bit
p = list(map(int, input().split()))

total = 0
for tbit in range(2 ** N):
  flg = True
  for i in range(M):
    bit = sbit[i] & tbit
    bits = 0
    while bit > 0:
      if bit & 1:
        bits += 1
      bit = bit >> 1
    if bits % 2 != p[i]:
      flg = False
      break
  if flg:
    total += 1
print(total)