import itertools
N,M=map(int,input().split())
L=[list(map(int,input().split())) for i in range(M)]
P=list(map(int,input().split()))
ans=0
for item in itertools.product(range(2),repeat=N):
  if all(sum(item[x-1] for x in L[i][1:])%2==P[i] for i in range(M)):
    ans+=1
print(ans)