n,m=map(int,input().split())
List=[list(map(int,input().split())) for i in range(m)]
P=list(map(int,input().split()))

k=0
ans=0
flug=True

for i in range(n):
    k=bin(i)
    for l in range(m):
        count=0
        for j in range(List[l][0]):
            if ((k>>List[l][j+1])&1)==1:
                count += 1
        if count%2 != P[l]:
            flug=False
    if flug==True:
        ans += 1
        
print(ans)