N,M = map(int,input().split())
ls = [list(map(int,input().split())) for _ in range(M)]
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)):
    flag = True
    for j in range(M):
        count = 0
        for k in range(1,len(ls[j])):
            if onof[i][k-1] == "1":
                count += 1
        if count%2 != p[j]:
            flag = False
            break
    if flag:
        ans += 1
print(ans)