let inp_matrix : 'a array -> int -> int -> unit = fun a m n ->
  for i = 0 to m - 1 do
    for j = 0 to n - 1 do
      a.(i).(j) <- Scanf.scanf " %d" (fun x -> x)
    done
  done

let rec inp_loop : (unit -> 'a) -> int -> 'a list = fun inp_fun n ->
  if n = 0 then []
  else
    let x = inp_fun () in
    x :: inp_loop inp_fun (n - 1)

let hole a m n k =
  for i = 0 to m - 1 do
    for j = 0 to n - 1 do
      if a.(i).(j) == k then
        a.(i).(j) <- (-1)
    done
  done

let calc_ans a =
  let ans = ref "No" in
  for i = 0 to 2 do
    if (a.(i).(0) == a.(i).(1) && a.(i).(0) == a.(i).(2)) then ans := "Yes"
  done;
  for j = 0 to 2 do
    if (a.(0).(j) == a.(1).(j) && a.(0).(j) == a.(2).(j)) then ans := "Yes"
  done;
  if (a.(0).(0) == a.(1).(1) && a.(2).(2) == a.(1).(1) || a.(0).(2) == a.(1).(1) && a.(0).(2) == a.(2).(0)) then ans := "Yes";
  !ans
  
  
let () =
  let a = Array.make_matrix 3 3 0 in
  let () = inp_matrix a 3 3 in
  let n = Scanf.sscanf (input_line stdin) "%d" (fun a -> a) in
  let l = inp_loop (fun () -> Scanf.sscanf (input_line stdin) "%d" (fun a -> a)) n in
  List.iter  (hole a 3 3) l;
  let ans = calc_ans a
  in
  print_endline ans;
