#include <stdio.h>
#include <stdlib.h>

#define tetra(N) N*(N+1)*(N+2)/6
#define isEven(N) N%2==0
#define N_MAX 1000000

int main(int argc, char* argv[]){
	int *min=malloc((N_MAX+1)*sizeof(int)), *minOdd=malloc((N_MAX+1)*sizeof(int)), i, n;
	
	/* initialize */
	for(i=1; i<=N_MAX; i++) min[i]=-1, minOdd[i]=-1;
	
	/* problem 1 */
	for(i=1; tetra(i)<=N_MAX; i++) min[tetra(i)]=1;
	for(i=1; i<=N_MAX; i++){
		int j, minLocal=N_MAX;
		if(min[i]!=-1) continue;
		for(j=1; i-tetra(j)>0; j++)
			if(min[i-tetra(j)]!=-1 && min[i-tetra(j)]+1<minLocal) minLocal=min[i-tetra(j)]+1;
		if(minLocal!=N_MAX) min[i]=minLocal;
	}
	
	/* problem 2 */
	for(i=1; tetra(i)<=N_MAX; i++){
		if(isEven(tetra(i))) continue;
		minOdd[tetra(i)]=1;
	}
	for(i=1; i<=N_MAX; i++){
		int j, minLocal=N_MAX;
		if(minOdd[i]!=-1) continue;
		for(j=1; i-tetra(j)>0; j++){
			if(isEven(tetra(j))) continue;
			if(minOdd[i-tetra(j)]!=-1 && minOdd[i-tetra(j)]+1<minLocal) minLocal=minOdd[i-tetra(j)]+1;
		}
		if(minLocal!=N_MAX) minOdd[i]=minLocal;
	}
	
	while(scanf("%d",&n), n!=0) printf("%d %d\n",min[n],minOdd[n]);
	
	free(min), free(minOdd);
}
	
	