import Data.List
import Control.Monad
import Data.Function

f :: Int -> Int -> Bool
f b k = if (n `mod` 2 == 0) && (2*b `mod` k == 0) && n > 0
        then True
        else False
    where n = (2*b`div`k-(k-1))

main :: IO ()
main = do
    fix $ \loop -> do
        b <- readLn
        unless (b == 0) $ do
            let k = head $ (filter (<= b) . filter (f b)) (reverse [1..10^5])
            let n = (2*b`div`k-(k-1)) `div` 2
            putStrLn $ show n ++ " " ++ show k
            loop
    return ()
