n, m = list(map(int, input().split()))
s = []
for i in range(m):
    tmp = list(map(int, input().split()))[1:]
    s.append(sum(2 ** (i - 1) for i in tmp))
p = list(map(int, input().split()))

c = 0
for i in range(2 ** n):
    for j in range(m):
        if bin(i & s[j]).count("1") % 2 != p[j]:
            break
    else:
        c += 1
print(c)