program bm
    implicit none
    integer::N,A(3,3),B
    logical::BINGO(3,3)=.false.,check=.false.
    integer::i,j,k
    do i=1,3
        read*,A(:,i)
    end do
    read*,N
    do i=1,N
        read*,b
        do j=1,3
            do k=1,3
                if(A(j,k)==b)BINGO(j,k)=.true.
            end do
        end do
    end do
    do i=1,3
        check=check.or.(Bingo(1,i).and.Bingo(2,i).and.bingo(3,i))
        check=check.or.(Bingo(i,1).and.Bingo(i,2).and.bingo(i,3))
    end do
    check=check.or.(Bingo(1,1).and.Bingo(2,2).and.bingo(3,3))
    check=check.or.(Bingo(1,3).and.Bingo(2,2).and.bingo(3,1))
    print"(A)",trim(merge("Yes","No ",check))
end program bm