#include #include #include #include #include #include using namespace std; int main() { int c; int cap; int height[100]; int ret[100]; int cnt = 0; int tmp_height = 1; int tmp_lines = 0; for ( ; ; ) { tmp_lines = tmp_lines * 3 + tmp_height * 2; height[cnt] = tmp_height; //printf ("%d ", height[cnt]); tmp_height *= 3; cnt++; if (tmp_height > 10000000) break; } //printf ("\n\n"); scanf ("%d", &c); while (c--) { memset (ret, 0, sizeof (ret)); scanf ("%d", &cap); int maxm = 0; int pos = cnt - 1; for ( ; ;) { if (cap >= height[pos]) { maxm = max (maxm, pos); cap -= height[pos]; //printf ("%d ", cap); ret[pos]++; continue; } if (pos == 0) break; pos--; } //printf ("<<\n"); for (int i = maxm; i > 0; i--) printf ("%d ", ret[i]); printf ("%d\n", ret[0]); } return 0; }