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 i in range(2**n):
    for ki, j in enumerate(k):
        target = j[1:]
        count = 0
        for t in target:
            if i & t == t:
                count += 1
        if count % 2 != p[ki]:
            break
    else:
        ans += 1
print(ans)
