n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    s=[0]*n
    f=1
    for j in range(n):
        if (i>>j)&1:
            s[j]=1
    for j in range(m):
        c=0
        for k in range(1,1+l[j][0]):
            if s[k-1]:
                c+=1
        if c%2!=p[j]:
            f=0
            break
    if f:
        ans+=1
print(ans)
