module Main (main) where
import Control.Applicative
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS
import Data.Function (fix)
import Data.Maybe (fromJust)
import Data.Vector ((!),Vector())
import qualified Data.Vector as V

getInt :: IO Int
getInt = fst . fromJust . BS.readInt <$> BS.getLine
main :: IO ()
main = do
  fix $ \continue -> do
    x <- getInt
    if (x == 0)
      then return ()
      else do
      putStrLn $ solve x
      continue
  return ()

solve :: Int -> String
solve x = show (dpTable 200 ! x) ++ ' ':show (dpTableOdd 200 ! x)

f :: Int -> Int
f n = n * (n+1) * (n+2) `div` 6

fs :: [Int]
fs = map f [1..]

fsOdd :: [Int]
fsOdd = filter odd fs

dpTable :: Int -> V.Vector Int
dpTable n = V.constructN n gen
  where
    gen :: V.Vector Int -> Int
    gen v
      | V.length v == 0 = 0
      | V.length v == 1 = 1
      | otherwise       = minimum [ 1 + v ! (k - fi) | fi <- takeWhile (\fi -> k - fi >= 0) fs]
      where
        k = V.length v
dpTableOdd :: Int -> V.Vector Int
dpTableOdd n = V.constructN n gen
  where
    gen :: V.Vector Int -> Int
    gen v
      | V.length v == 0 = 0
      | V.length v == 1 = 1
      | otherwise       = minimum [ 1 + v ! (k - fi) | fi <- takeWhile (\fi -> k - fi >= 0) fsOdd]
      where
        k = V.length v
        
       