Go: package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	var nums []int
	for i := 1; i < 2*100+1; i++ {
		nums = append(nums, i*(i+1)*(i+2)/6)
	}
	var ins []int
	N := 0
	for true {
		n := sc.nextInt()
		if n == 0 {
			break
		}
		ins = append(ins, n)
		N = max(N, n)
	}
	dp := make([]int, N+1)
	dp2 := make([]int, N+1)
	for i := 1; i < N+1; i++ {
		dp[i] = INF
		dp2[i] = INF
	}
	for i := 0; i < len(nums); i++ {
		n := nums[i]
		if n > N {
			break
		}
		for j := 0; j < N+1; j++ {
			if j >= n {
				dp[j] = min(dp[j], dp[j-n]+1)
				if n%2 != 0 {
					dp2[j] = min(dp2[j], dp2[j-n]+1)
				}
			}
		}
	}
	for i := 0; i < len(ins); i++ {
		fmt.Fprintln(wtr, dp[ins[i]], dp2[ins[i]])
	}
}

C++: #include <iostream>
#include <vector>
#include <list>
#include <set>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <deque>

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using pii=pair<int,int>;
using vs=vector<string>;
using vvi=vector<vi>;
using vpii=vector<pii>;
using si=set<int>;


#define REP(i,a) for(int i=0;i<a;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rREP(i,a) for(int i=(a)-1;i>=0;i--)
#define rFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define out(S) cout<<(S)<<endl;
#define beginend(v) (v).begin(),(v).end()
#define IfOut(condition,text) if(condition){out(text);return 0;}
#define IfOutElse(condition,if_text,else_text) if(condition){out(if_text);return 0;}else{out(else_text);return 0;}
#define mod(s) ((s)%(ll)(1e9+7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a*modpow((ll)b,(ll)(1e9+5))))
#define pb(i) push_back(i)
#define fst first
#define snd second
#define Foreach(item,collection) for(auto item:collection)
#define INF (int)1e10
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) {ll prime;double sqrtmax = sqrt(max);vector<ll> primeVec, searchVec;FOR(i, 2, max + 1) searchVec.push_back(i);do{prime = searchVec[0];primeVec.push_back(prime);auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });searchVec.erase(itr, searchVec.end());} while (prime < sqrtmax);primeVec.reserve(primeVec.size() + searchVec.size());primeVec.insert(primeVec.end(), beginend(searchVec));return primeVec;}
ll sum(vi v) {ll sum=0;Foreach(i,v){sum+=i;}return sum;}
#define ShowAll(v) Foreach(i,v) out(i);
bool isInnerIndex(int kx,int ky,int mx,int my){ return (kx>=0&&kx<mx&&ky>=0&&ky<my); }
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;

vi llist,oddlist;

void makeList(int max){
    int n=1;
    bool f=true;
    while(f){
        ll next=n*(n+1)*(n+2)/6;
        if(next>max){break;}
        llist.pb(next);
        if(next%2==1) oddlist.pb(next);
        n++;
    }
}


int beam_width=15000;

int bfs(int target){
    deque<int> q;
    int mm=0;
    Foreach(i,llist) {
        if(i==target){
            return 1;
        }
        if(i<target){
            q.pb(i);
            mm=i;
        }
        if(i>target) break;
    }
    //auto mm=*max_element(beginend(q));
    int cnt=0;
    if(binary_search(beginend(q),target)) return cnt+1;
    cnt+=2;
    while(1){
        deque<int> next;
        Foreach(x,q){
            if(binary_search(beginend(llist),target-x)){
                next.clear();
                q.clear();
                return cnt;
            }
            Foreach(k,llist){
                if(k+x>target) break;
                // if(k+x==target) {next.clear();q.clear();return cnt;}
                if(k+x<target) next.pb(k+x);
            }

            
        }
        sort(beginend(next));
        next.erase( unique(beginend(next)),next.end());
        int ns=next.size();
        REP(i,ns-beam_width){
            next.pop_front();
        }
        q=next;
        next.clear();
        cnt++;
    }
}

int bfs2(int target){
    deque<int> q;
    int mm=0;
    Foreach(i,oddlist){
        if(i==target) return 1;
        if(i<target) {q.pb(i);mm=i;}
        if(i>target) break;
    }
    int cnt=(target-mm)/mm;
    target=target%mm+mm;
    if(binary_search(beginend(q),target)) return cnt+1;
    cnt+=2;
    //out(mm);
    while(1){
        deque<int> next;
        Foreach(x,q){
            if(binary_search(beginend(oddlist),target-x)){
                next.clear();
                q.clear();
                return cnt;
            }
            Foreach(k,oddlist){
                if(k+x>target)break;
                //if(k+x==target){next.clear();q.clear();return cnt;}
                if(k+x<target)next.pb(k+x);
            }
        }
        sort(beginend(next));
        next.erase( unique(beginend(next)),next.end());
        int ns=next.size();
        REP(i,ns-beam_width){
            next.pop_front();
        }
        q=next;
        next.clear();
        cnt++;
    }
}



int main(){
    int n;
    vl query;
    int mm=0;
    while (cin>>n,n)
    {
        query.pb(n);
        mm=max(mm,n);
    }
    map<int,pii> m;
    makeList(mm);
    Foreach(i,query){
        if(m.count(i)!=0){
            cout<<m[i].first<<" "<<m[i].second<<endl;
            continue;
        }
        int ans1=bfs(i);
        int ans2=bfs2(i);
        //int ans2=0;
        m[i]=pii(ans1,ans2);
        cout<<ans1<<" "<<ans2<<endl;
    }
    return 0;
}