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