n,m=map(int,input().split())
k=[0]*m
s=[0]*m
for i in range(m):
  tmp = list(map(int,input().split()))
  k[i] = tmp[0]
  s[i] = tmp[1:]
p=list(map(int,input().split()))

res=0
for bit in range(2**n):
  for i in range(m):
    cnt=0
    for sw in s[i]:
      if (bit >> (sw-1) & 1):
        cnt += 1
    if cnt % 2 != p[i]:
      break
  else:
    res+=1
print(res)