

n,m=map(int,input().split())
K=[list(map(int,input().split())) for _ in range(m)]
P=list(map(int,input().split()))

ans = 0

for bits in range(2 ** n):
    ok = True
    for i, k in enumerate(K):
        ok = ok and sum((bits >> (s - 1)) & 1 for s in k[1:]) % 2 == P[i]
    if ok:
        ans += 1
        

print(ans)
