program example
	implicit none
    
    integer N,A(3,3),i,j,k,count
    integer,allocatable :: b(:)
    
    do i=1,3
    	read(*,*) A(i,1:3)
    end do
    
    read(*,*) N
    
    allocate (b(N))
    
    do i=1,N
    	read(*,*) b(i)
    end do
    
    do i=1,3
    	do j=1,3
        	count=0
        	do k=1,N
            	if(A(i,j)==b(k)) then
                	count=count+1
                end if
            end do
            
            if (count==3) then
            	write(*,*) "Yes"
                goto 1
    		end if
        end do
    end do

    do i=1,3
    	do j=1,3
        	count=0
        	do k=1,N
            	if(A(j,i)==b(k)) then
                	count=count+1
                end if
            end do
            
            if (count==3) then
            	write(*,*) "Yes"
                goto 1
    		end if
        end do
    end do
    
    count=0
    
    do i=1,3
    	do j=1,N
    		if(A(i,i)==b(j)) then
            	count=count+1
            end if
        end do
    end do
    
    if (count==3) then
    	write(*,*) "Yes"
        goto 1
    end if
    
    count=0
    
    do i=1,N
    	if(A(1,3)==b(i)) then
        	count=count+1
        end if

    	if(A(2,2)==b(i)) then
        	count=count+1
        end if

    	if(A(3,1)==b(i)) then
        	count=count+1
        end if
    end do
    
    if (count==3) then
    	write(*,*) "Yes"
        goto 1
    end if
    
    write(*,*) "No"
    
    
1 end program example