n;f(x,a,b,c){return x?x%b/c+10*f(x-x%b,a+1,a*b,b):0;}main(){while(n<1001)printf("%d\n",f(n++,3,2,1)*10);}