open Printf
open Scanf

let id x = x

let find_index ar x =
  let rec loop i =
    if i > 8 then None
    else if ar.(i) = x then Some i
    else loop (i + 1) in
  loop 0

let solve () =
  let tbl = Array.init 9 @@ fun _ -> scanf "%d " id in
  let n = scanf "%d " id in
  let ar = Array.init n @@ fun _ -> scanf "%d " id in
  Array.iter (fun x -> match find_index tbl x with
                         Some i -> tbl.(i) <- 0
                       | None -> ()) ar;
  if tbl.(0) = 0 && tbl.(1) = 0 && tbl.(2) = 0 ||
     tbl.(3) = 0 && tbl.(4) = 0 && tbl.(5) = 0 ||
     tbl.(6) = 0 && tbl.(7) = 0 && tbl.(8) = 0 ||
     tbl.(0) = 0 && tbl.(3) = 0 && tbl.(6) = 0 ||
     tbl.(1) = 0 && tbl.(4) = 0 && tbl.(7) = 0 ||
     tbl.(2) = 0 && tbl.(5) = 0 && tbl.(8) = 0 ||
     tbl.(0) = 0 && tbl.(4) = 0 && tbl.(8) = 0 ||
     tbl.(2) = 0 && tbl.(4) = 0 && tbl.(6) = 0 then "Yes" else "No"
let () =
  solve () |> printf "%s\n"
