n,m=map(int,input().split())
sw=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))

ans=0
for i in range(2**n):
    f=1
    for j in range(m):
        c=0
        for x in sw[j][1:]:
            x-=1
            c+=(i>>x)&1
        if c%2!=p[j]:
            f=0
    ans+=1 if f else 0
print(ans)
