N,M = map(int,input().split())
ls = []
for i in range(M):
    tmp = list(map(int,input().split()))
    ls.append(tmp[1:])
p = list(map(int,input().split()))
onof=[bin(x)[2:].zfill(N) for x in list(range(2**N))]
ans = 0
for i in range(len(onof)):
    all = True
    for j in range(M):
        num = 0
        for k in range(len(ls[j])):
            if onof[i][k-1] == "1":
                num += 1
        if num%2 != p[j]:
            all = False
            break
    ans += all
print(ans)