fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf
    .trim()
    .split_whitespace()
    .map(|x| x.parse().ok().unwrap())
    .collect()
}

fn main() {
  let v: Vec<usize> = read_vec();
  let (n, m) = (v[0], v[1]);
  let lights: Vec<Vec<usize>> = (0..m).map(|_| read_vec()).collect();
  let ps: Vec<usize> = read_vec();

  let mut ans = 0;
  for i in 0..(2_u32.pow(n as u32)) as usize {
    let bits: Vec<char> = format!("{:09b}", i).chars().rev().collect();
    let mut all = true;
    for (j, light) in lights.iter().enumerate() {
      let cnt = &light[1..].iter().filter(|&s| bits[s - 1] == '1').count();
      if cnt % 2 != ps[j] {
        all = false;
        break;
      }
    }
    if all {
      ans += 1;
    }
  }
  println!("{}", ans);
}
