n,m=map(int,input().split())
ans=0

s=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
for  i in range(1<<(n)):
    for j in range(m):
        c=0
        for ss in s[j][1:]:
            if i&(1<<(ss-1)):
                c+=1
        if c%2!=p[j]:
            break
    else:
        ans+=1

print(ans)