import itertools
N,M=map(int,input().split())
L=[list(map(int,input().split()))[1:] for i in range(M)]
P=list(map(int,input().split()))

A=list(itertools.product([0,1],repeat=N))

ans=2**N
for i in range(2**N):
  for j in range(M):
    cnt=0
    for k in L[j]:
      cnt+=A[i][k-1]
    if P[j]!=(cnt%2):
      ans-=1
      break
print(ans)