import itertools

n, m = [int(_) for _ in input().split()]
ks = []
cnt = 0

for i in range(m):
    ks.append([int(_) for _ in input().split()])
p = [int(_) for _ in input().split()]

for np in itertools.product((0,1), repeat=n):
    s = 0 
    for i in range(m):
        for j in range(1, ks[i][0]+1):
            s += np[ks[i][j]-1]
        if p[i] != s%2:
            break
    else:
        cnt += 1
print(cnt)
