let () =
  let num_card =
    Array.init 3 @@ fun _ ->
      Array.init 3 @@ fun _ ->
        Scanf.scanf " %d" @@ Fun.id in
  let mark = Array.make_matrix 3 3 false in
  Scanf.scanf "%d\n" @@ fun n ->
    for i = 0 to n - 1 do
      Scanf.scanf "%d\n" @@ fun b ->
        for i = 0 to 2 do
          for j = 0 to 2 do
            if num_card.(i).(j) = b then mark.(i).(j) <- true
          done
        done
    done;
    print_endline @@
    if
      mark.(0) = [| true; true; true |] ||
      mark.(1) = [| true; true; true |] ||
      mark.(2) = [| true; true; true |] ||
      Array.init 3 (fun i -> mark.(i).(0)) = [| true; true; true |] ||
      Array.init 3 (fun i -> mark.(i).(1)) = [| true; true; true |] ||
      Array.init 3 (fun i -> mark.(i).(2)) = [| true; true; true |] ||
      Array.init 3 (fun i -> mark.(i).(i)) = [| true; true; true |] ||
      Array.init 3 (fun i -> mark.(2-i).(i)) = [| true; true; true |]
    then "Yes"
    else "No"