Scanf.scanf "%d %d" @@ fun n m ->
  let sss = Array.init m @@ fun _ ->
    let k = Scanf.scanf " %d" @@ (+) 0 in
    Array.init k @@ fun _ -> Scanf.scanf " %d" @@ fun s -> s - 1 in
  let ps = Array.init m @@ fun _ -> Scanf.scanf " %d" @@ (+) 0 in
  let array_count f = Array.fold_left (fun n x -> if f x then n + 1 else n) 0 in
  let array_for_all f xs = Array.length xs = array_count f xs in
  let flags = Array.make n false in
  let is_on i =
    let ss = sss.(i) in
    let c = ref 0 in
    for j = 0 to Array.length ss - 1 do
      if flags.(ss.(j)) then incr c
    done;
    !c mod 2 = ps.(i) in
    (* let c = array_count ((=) true) flags in c mod 2 = ps.(i) in *)
  let judge () = array_for_all is_on @@ Array.init m @@ (+) 0 in
  let ans = ref 0 in
  let rec find i =
    (* Array.iter (fun x -> print_string @@ if x then "true " else "false ") flags;
    print_newline (); *)
    (* Printf.printf "%d %d\n" i n; *)
    if i >= n then
      (if judge () then incr ans)
    else
      (flags.(i) <- true;
      find (i + 1);
      flags.(i) <- false;
      find (i + 1)) in
  find 0;
  Printf.printf "%d\n" !ans