n,m=map(int,input().split())
s=[list(map(int,input().split()))[1:]for _ in range(m)]
*p,=map(int,input().split())
print(sum([all([sum([i>>(k-1)for k in s[j]])%2==p[j]for j in range(m)])for i in range(2**n)]))