(* O(2^n) *)
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 is_on bits i =
    let ss = sss.(i) in
    let c = ref 0 in
    for j = 0 to Array.length ss - 1 do
      if (bits lsr ss.(j)) land 1 = 1 then incr c
    done;
    !c mod 2 = ps.(i) in
  let judge bits = array_for_all (is_on bits) @@ Array.init m @@ (+) 0 in
  let ans = ref 0 in
  for i = 0 to 1 lsl n - 1 do
    if judge i then incr ans
  done;
  Printf.printf "%d\n" !ans