SN,LN=map(int,input().split())
S=[list(map(int,input().split())) for _ in range(LN)]
p=list(map(int,input().split()))

c=0
for i in range(1<<SN):
  tmp=[0]*SN
  for j in range(SN):
    if (i>>j)&1==1:
      tmp[j]=1
      judge=True
  for k in range(LN):
    sum=0
    for x in S[k][1:]:
      if tmp[x-1]==1:
        sum+=1
    if sum%2!=p[k]:
      judge=False
  if judge:
    c+=1

print(c)

  
