n, m = [int(i) for i in input().split()]
K = [[int(i) for i in input().split()] for j in range(m)]
P = [int(i) for i in 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)