n, m = map(int, input().split())
s = []
k = []
for i in range(m):
    ipt = list(map(int, input().split()))
    k.append(ipt[0])
    s.append(ipt[1:])
p = list(map(int, input().split()))
cnt = 0
for sw in (list(format(i, f'0{n}b')) for i in range(2 ** n)):
    for i in range(m):
        if sum([int(sw[j - 1]) for j in s[i]]) % 2 != p[i]:
            break
    else:
        cnt += 1
print(cnt)