n,m = map(int, input().split())#n個のスイッチのオンオフの組み合わせ
ks = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))#0/1⇒偶数or奇数
num=2**n
ans=0
for i in range(num+1):
    bin_i = str(bin(i))
    bin_i = bin_i[2:len(bin_i)]
    res = n-len(bin_i)
    bin_i = "0"*res + bin_i
    on=0
    for j in range(m):
        s_num=0
        for k in range(1, ks[j][0]+1):
            if bin_i[ks[j][k]-1] == "1":
                s_num+=1
        if s_num%2==p[j] and s_num!=0:
            on+=1
        else:
            break
    if on==m:
        ans+=1
print(ans)