program sample
    implicit none
  
    integer(8) :: i,j,k,m,n,h,w,b
    

    integer(8)::a(3,3),che(3,3)
    read(*,*) a
    read(*,*) n
    
    do i=1,n
        read(*,*)b
        do j=1,3
            do k=1,3

                if (b==a(j,k))then
                    che(j,k)=1
                end if

            end do
        end do
    end do
    do i=1,3
        if ((che(i,1)==1 .and. che(i,2)==1 .and. che(i,3)==1))then
            write(*,*)'Yes'
            stop
        end if
    end do
    do i=1,3
        if ((che(1,i)==1 .and. che(2,i)==1 .and. che(3,i)==1))then
            write(*,*)'Yes'
            stop
        end if
    end do
    
    if ((che(1,1)==1 .and. che(2,2)==1 .and. che(3,3)==1))then
            write(*,*)'Yes'
            stop
    end if
    

    if ((che(1,3)==1 .and. che(2,2)==1 .and. che(3,1)==1))then
        write(*,*)'Yes'
        stop
    end if

    write(*,*)'No'
    stop
end program sample
  

