program Bingo
    implicit none
    integer(4):: bng(3,3), num
    integer(4):: i,j,k, n
    logical:: is_open(3,3) = .false.

    do i=1, 3
        read*, bng(:,i)
    end do

    read*, n

    do i=1, n
        read*, num

        do j=1,3
            do k=1,3
                if (bng(k,j) == num) is_open(k,j) = .true.  
            end do
        end do
    end do

    if (check_bingo(is_open)) then
        print*, 'Yes'
    else
        print*, 'No'
    end if

    contains
    function check_bingo(is_open) result(is_bingo)
        integer(4):: i,j
        logical:: is_open(3,3), is_bingo

        is_bingo = .false.

        do i=1, 3
            if (is_open(1,i) .and. is_open(2,i) .and. is_open(3,i)) is_bingo = .true.
            if (is_open(i,1) .and. is_open(i,2) .and. is_open(i,3)) is_bingo = .true.
        end do

        if (is_open(1,1) .and. is_open(2,2) .and. is_open(3,3)) is_bingo = .true.
        if (is_open(1,3) .and. is_open(2,2) .and. is_open(3,1)) is_bingo = .true.
        
    end function
end program Bingo