import numpy as np
N, M = map(int, input().split())

#create 0/1 matrix for all lamps and switches 
s=np.zeros((M,N))
for i in range(M):
    ks = list(map(int, input().split()))  
    for j in range(ks[0]):
        s[i, ks[j+1]-1]=1
P = list(map(int, input().split()))      
    
#remove any swith not connected to any lamp
s_sum_index = np.sum(s, axis=0) != 0
s1 = s[:,s_sum_index]

#print(s1)
counter=0
# 2^N possible combinations of switches
for k in range(2**s1.shape[1]):
    k_bit = list(map(int, list(np.binary_repr(k, s1.shape[1]))))
    #calculate how many switches are on for each lamp
    b_status = np.dot(s1, k_bit)%2
    #print(k_bit, b_status)
    if all(b_status==P)==True:
        counter +=1

print(counter)