#include static unsigned edges[13]; static unsigned nodes[13]; void solve(unsigned capacity) { int i = 1; //printf("solving\n"); while(i < 13) { //printf("while %u\n", i); if(nodes[i] == 0) { nodes[i] = nodes[i-1] * 3; edges[i] = 2 * nodes[i-1] * i; } if(nodes[i] >= capacity) break; ++i; } for(--i; i >= 0; --i) { int count = 0; while(capacity >= nodes[i]) { capacity -= nodes[i]; ++count; } printf("%d ", count); } printf("\n"); } int main() { int tests; nodes[0] = 1; edges[0] = 0; scanf("%d", &tests); for(int i = 0; i < tests; ++i) { unsigned capacity; scanf("%u", &capacity); solve(capacity); } }