n, m = (int(_) for _ in input().split())  
skp = [[int(i) for i in input().split()] for i in range(m+1)]
sk, p = skp[:-1], skp[-1]

def judge(sw_status, sk, p):
  sk = np.array(sk) - 1
  num = sw_status[sk[1:]].sum()%2
  if num == p:
    light = 1
  else:
    light = 0
  return light

# sw_status = np.array([0 for i in range(n)])
ans = 0
for i in range(2**n):
  sw_status = [j for j in bin(i)][2:]
  for SK, P in zip(sk, p):
  	j = judge(sw_status, SK, P)
    if j==0:
      break
    else:
      ans += 1

print(ans)