program yukicoder_2493 use, intrinsic :: iso_fortran_env implicit none integer(int32) :: q, d, k integer(int32) :: lt_points, le_points integer(int32) :: x, y integer(int32) :: i read(input_unit, *) q query: do i = 1, q read(input_unit, *) d, k if (d == 0) then if (k == 1) then write(output_unit, '(a)') "Yes" write(output_unit, '(*(i0, 1x))') 0, 0 else write(output_unit, '(a)') "No" end if cycle query end if lt_points = 0_int32 le_points = 0_int32 do x = d / 2, 0, -1 y = d - x lt_points = le_points le_points = le_points + merge(4, 8, 2 * x == d .or. x == 0) if (lt_points < k .and. le_points >= k) then write(output_unit, '(a)') "Yes" write(output_unit, '(*(i0, 1x))') x, y cycle query end if end do write(output_unit, '(a)') "No" end do query end program yukicoder_2493