{-# LANGUAGE PartialTypeSignatures #-}
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = readInts >>= output . solve

solve :: [Int] -> _
solve [x] = head [i | i <- [1..], i^5 == x-1]
  where
    y = if null (prime_factors x) then 0 else head (prime_factors x)

    prime_factors :: Int -> [Int]
    prime_factors 1 = []
    prime_factors n
      | factors == []  = [n]
      | otherwise = factors ++ prime_factors (n `div` (head factors))
      where factors = take 1 $ filter (\x -> (n `mod` x) == 0) [2 .. n-1]

output :: _ -> IO ()
output a = putStrLn (show a <> " " <> show (-1))

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine
