program bingo
  implicit none
  integer :: a(3,3), n, b, i, j, k
  logical :: x
  read(*,*) a
  read(*,*) n
  do i = 1, n
    read(*,*) b
    do j = 1, 3
      do k = 1, 3
        if (a(j,k) == b) a(j,k) = -1
      end do
    end do
  end do
  x = x .or. (a(1,1) < 0 .and. a(2,2) < 0 .and. a(3,3) < 0) .or. (a(3,1) < 0 .and. a(2,2) < 0 .and. a(1,3) < 0)
  do i = 1, 3
    x = x .or. all(a(i,:) < 0) .or. all(a(:,i) < 0)
  end do
  write(*,'(a)') trim(merge("Yes","No ",x))
end program bingo