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 i in range(2**n):
    f = 1
    for j in range(m):
        g = 1
        g &= (sum([int(bin(i>>(u-1)),2) for u in s[j]])%2 == p[j])
        f &= g
    ans += f
print(ans)