n,m = map(int,input().split())
u = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))

import itertools
sw = list(itertools.product([0,1],repeat=n))

count = 0
temp=0
for i in range(2**n):
    for j in range(m):
        for s in u[j][1:]:
            if sw[i][s-1]==1:
                temp+=1
        if temp%2!=p[j]:
            break
    else:
        count+=1

print(count)