n,m=map(int,input().split())
S=[]
for _ in range(m):
    s=list(map(int,input().split()))
    S.append(s[1:])
P=tuple(map(int,input().split()))
ans=0
for i in range(1<<n):
    for j in range(m):
        cnt=0
        for k in S[j]:
            if i&(1<<(k-1)):
                cnt+=1
        if cnt%2!=P[j]:
            break
    else:
        ans+=1
print(ans)