N,M = [int(x) for x in input().split()]


inn = []
for i in range(M):
    inn.append([int(x) for x in input().split()][1:])
    
p = [int(x) for x in input().split()]
ans = 0
for i in range(2**N):
    b = "0"*(N-len(bin(i)[2::]))+bin(i)[2::]
 #   print(b)
    s = 0
    flag = True
    for j in range(M):
        for k in inn[j]:
            if b[k-1] == "1":
                s += 1
    
        if s % 2 != p[j]:
            flag = False
#            print(b,s)
            break
        
    if flag:
        ans += 1

print(ans)
