#include #include int main(void) { int n, weight; scanf("%d", &n); for(int i = 0; i < n; i++){ scanf("%d", &weight); bool first = false; for(int j = 220; j >=0; j--) { int count = pow(3,j); int tmp = 0; if(weight>0) while(weight-count >= 0) { tmp++; weight = weight-count; } if(tmp > 0) { first = true; } if(first) { if(j == 0) printf("%d", tmp); else printf("%d ", tmp); } } printf("\n"); } return 0; }