N = 1_000_000

def unbounded_knapsack(items, budget)
	table = [0]
	items.sort_by!(&:first)
	valid_items = []
	for i in 1..budget
		table[i] = -Float::INFINITY
		valid_items << items.shift while !items.empty? && items[0][0] <= i
		valid_items.each{|c, v|
			x = table[i-c] + v
			table[i] = x if x > table[i]
		}
	end
	table
end

t = -> n { n * (n+1) * (n+2) / 6 }
n = 1
items = []
odd_items = []
while t[n] < N
	items << [t[n], -1] 
	odd_items << items[-1]  if items[-1][0].odd?
	n += 1
end

pollock = unbounded_knapsack(items, N)
odd_pollock = unbounded_knapsack(odd_items, N)

loop do
	n = gets.to_i
	break if n == 0
	puts [-pollock[n], -odd_pollock[n]] * ' '
end