n, m = [int(i) for i in input().split()]
k = []
s = []
for i in range(m):
    tmp = [int(i) for i in input().split()]
    k.append(tmp[0])
    s += [tmp[1:]]
p = [int(i) for i in input().split()]
cnt = 0

for b in range(1 << n):
    sw = [0] * n
    for i in range(n):
        if b & (1 << i): sw[i] = 1
    for i in range(m):
        c = 0
        for j in s[i]:
            if sw[j - 1] == 1: c += 1
        if c % 2 == p[i]: break
        cnt += 1
print(cnt)
