n,m = list(map(int,input().split()))
l_list = [list(map(int,input().split())) for i in range(m)] 
p = list(map(int,input().split()))
output = 0

for i in range(2 ** n):
  lights = []
  for j in range(n+1):
    if ((i >> j) & 1):
      lights.append(j+1)
      
  for l in l_list:
    if len(set(l[1:]) & set(lights)) % 2 != p[l[0]-1]:
      break
  else:
    output += 1
print(output)