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

ans = 0
for item in itertools.product([0, 1], repeat=n):
    for i in range(m):
        if sum([item[j-1] for j in s[i]]) % 2 != p[i]:
            break
    else:
        ans += 1
print(ans)
