N,M=map(int,input().split())
K=[list(map(int,input().split()))[1:] for _ in range(M)]
p=list(map(int,input().split()))
#print(K)

L=[0 for i in range(2**N)]
#print(L)

for i in range(2**N):
  cnt=0
  for j in range(M):
    for k in K[j]:
      if (i>>(k-1))&1==1:
        cnt+=1
    if cnt%2==p[j]:
      L[i]+=1
#print(L)

ans=0
for i in L:
  if i==M:
    ans+=1
print(ans)