N,M=map(int,input().split())
A=[0]*M
for i in range(M):
 A[i]=list(map(int,input().split()))
P=list(map(int,input().split()))
F=0
for i in range(2**N):
 E=0
 Sui=[0]*N
 for j in range(N):
  if ((i >> j) & 1):
   Sui[j]+=1
 for k in range(M):
  D=0
  for l in range(1,A[k][0]+1):
   if Sui[A[k][l]-1]==1:
    D+=1
  if D%2==P[k]:
   E+=1
 if E==M:
  F+=1
print(F)