import numpy as np

N, M = map(int, input().split())
connect = [0] * M
for j in range(M):
  connect_list = [int(s) for s in input().split()[1:]]
  connect[j] = sum(np.array(connect_list))
plist = list(map(int, input().split()))

count = 0
for n in range(2**N):
  for j in range(M):
    switch_on = n & connect[j]
    num_switch_on = [int(k) for k in str(bin(switch_on))[2:]]
    if (sum(np.array(num_switch_on)) % 2) != plist[j]:
  		 break
    if j == M-1:
        count += 1
  
print(count)