n, m = map(int, input().split())
bulbs = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
cmb = [1] * 2 ** n

for i in range(2 ** n):
    on_off = [0] * n
    for j in range(n):
        if i >> j & 1:
            on_off[j] = 1
    
    cnt = 0
    for j in range(m):
        for k in bulbs[j][1:]:
            cnt += on_off[k - 1]
        if cnt % 2 != p[j]:
            cmb[i] = 0
            
print(sum(cmb))