N, M = map(int, input().split())
den_lists = []
for m in range(M):
    den_lists.append(list(map(int, input().split())))
p = list(map(int, input().split()))
#print(p)
count = 0

for i in range(2**N+1):
    s_list = []
    for j in range(N):
        if (i >> j) & 1:
            s_list.append(j)
    #print(f"s_list:{s_list}")     
    den_count = 0
    for m, den in enumerate(den_lists):
        tmp = 0
        for d in den[1:]:
            if d-1 in s_list:
                tmp += 1
        #print(f"tmp:{tmp}")        
        if tmp % 2 == p[m]:
            #print(m)
            den_count += 1
    #print(f"den_count:{den_count}")
        
    if den_count == len(den_lists):
        count += 1
        
    
    

print(count)