program i_hate_factorization
  implicit none
  integer(8) :: x, i, g = 1_8, i5, r
  read(*,*) x
  do i = 2_8, x
    i5 = i*i*i*i*i
    if (i5 > x) exit
    do while (mod(x,i5) == 0_8)
      x = x/i5
      g = g*i
    end do
  end do
  do i = 1_8, x
    if (mod(x,i) /= 0_8) cycle
    if (x/i < i) exit
    call find(i)
    call find(-i)
  end do
contains
  subroutine find(p)
    integer(8), intent(in) :: p
    integer(8) :: i, q, r
    do i = 0_8, 1000000000_8
      q = p*(5_8*i*i*i*i+10_8*i*i*i*p+10_8*i*i*p*p+5_8*i*p*p*p+p*p*p*p)
      r = p*(5_8*i*i*i*i-10_8*i*i*i*p+10_8*i*i*p*p-5_8*i*p*p*p+p*p*p*p)
      if (abs(q) > 1000000_8*x .and. abs(r) > 1000000_8*x) exit
      if (q == x) then
        write(*,'(i0,x,i0)') (i+p)*g, i*g
        stop
      end if
      if (r == x) then
        write(*,'(i0,x,i0)') (-i+p)*g, -i*g
        stop
      end if
    end do
  end
end program i_hate_factorization