import itertools
n,m=map(int,input().split())
L=[]
for i in range(m):
  a,*l=map(int,input().split())
  L+=[l]
S=list(map(int,input().split()))
ans=0
for i in itertools.product([0,1], repeat=n):
  f=0
  for l,s in zip(L,S):
    ls=0
    for ll in l:
      ls+=i[ll-1]
    if ls%2==s:
      f+=1
  if f==m:
    ans+=1
print(ans)