n,m=map(int,input().split())
b=[0]*m
for i in range(m):
  a=list(map(int,input().split()))
  b[i]=a
p=list(map(int,input().split()))
z=0
for i in range(0,2**n):  
  sl=[int(x) for x in list(str(bin(i+2**n)[2:]))]
  flag=0
  for j in range(m):
    s=0
    for l in range(1,b[j][0]):
      s=s+sl[b[j][l]]
    if s%2!=p[j]:
      flag=1
  if flag==0:
    z=z+1
print(z)