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

res = 0
for i in range(2**n):
    x = bin(i)[2:][-n:].zfill(n)
    if all([sum([int(x[ii-1]) for ii in l[i]]) % 2 == p[i] for i in range(len(l))]):
        res += 1
print(res)
