from itertools import permutations, combinations,combinations_with_replacement,product
n,m=map(int, input().split())

a=[list(map(int, input().split())) for i in range(m)]
p=list(map(int, input().split()))
count=0
for sw in product([0,1],repeat=n):
    flag=1
    on=0
    for i in range(m):
        for j in range(a[i][0]):
            on+=sw[a[i][j+1]-1]
        
        if on%2!=p[i]:
            flag=0
        #print(on,sw,p[i],flag, on%2!=p[i])
    count+=flag
print(count)