N,M=map(int,input().split())
S=[list(map(int,input().split()))[1:] for i in range(M)]
P=list(map(int,input().split()))
#print(S)
#print(P)

ans=0
for i in range(2**N):
  #print(bin(i))
  p=[]
  for s in S:
    tmp=0
    for ss in s:
      if i>>(N-ss)&1:
        tmp+=1
    p.append(tmp%2)
  if p==P:
    ans+=1
print(ans)