(* 2^n * nm *)
let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let sss = Array.init m @@ fun _ -> Scanf.scanf " %d" @@ fun k -> Array.init k @@ fun _ -> Scanf.scanf " %d" @@ fun s -> s - 1
let ps = Array.init m @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let f ss bits p =
  Array.fold_left (fun acc s -> if bits lsr s land 1 = 1 then acc + 1 else acc) 0 ss mod 2 = p
let rec check i bits =
  if i >= m then true
  else if not @@ f sss.(i) bits ps.(i) then false
  else check (i + 1) bits
let ans = ref 0
let _ =
  for i = 0 to 1 lsl n - 1 do if check 0 i then incr ans done;
  Printf.printf "%d\n" !ans