N,M=map(int,input().split())
ls=[]
cnt,cnt2,ans=0,0,0
for i in range(M):
    ls1=list(map(int,input().split()))
    ls.append(list(ls1))
    ls1.clear()
lsp = list(map(int,input().split()))
#print(ls)
#print(lsp)
for i in range(2**N):
    flg = True
    for j in range(M):
        cnt = 0
        for k in range(1,len(ls[j])):
            if i >> ls[j][k] & 1:
                cnt += 1
        if cnt%2 != lsp[j]:
            flg = False
    if flg:
        ans += 1
print(ans)
