n, m = map(int, input().split())
k = []
for _ in range(m):
    k.append(list(map(int, input().split()))[1:])
*p, = map(int, input().split())

count = 0
for i in range(2 ** n):
    res = 0
    for kc, pc in zip(k, p):
        s = sum([(i >> (j-1)) & 1 for j in kc]) % 2
        res += s == pc
    count += res == len(p)
print(count)