n,m = map(int,input().split())
check = []
for i in range(m):
    l = list(map(int,input().split()))
    check.append(l[1:])
p = list(map(int,input().split()))
count = 0

for i in range(2**n+1):
    check2 = [0]*m
    for j in range(n):
        if ((i>>j) & 1):
            for k in range(m):
                
                if j+1 in check[k]:
                    check2[k] += 1
                    
    check3 = True
    for l in range(m):
        if check2[l]%2 != p[l]:
            check3 = False
    if check3 :
        count += 1
        

print(count)

