#include #include using namespace std; int main() { int pocet; cin >> pocet; int dimenze = 20; int vahy[dimenze]; int ceny[dimenze]; vahy[0] = 1; ceny[0] = 1; for(int i = 1; i < dimenze ; i++) { vahy[i] = vahy[i - 1] * 3; ceny[i] = (3 * ceny[i - 1]) + (2 * vahy[i - 1]); //cout << ceny[i] << " " ; } for(int x = 0; x < pocet; x++) { int nosnost; bool zapis = true; cin >> nosnost; for(int i = dimenze - 1; i >= 0; i--) { if(nosnost < vahy[i] && zapis) continue; else { zapis = false; if(2 * vahy[i] <= nosnost) { nosnost -= 2 * vahy[i]; cout << 2; }else if(vahy[i] <= nosnost) { nosnost -= vahy[i]; cout << 1; }else if(vahy[i] > nosnost) { cout << 0; } if(i != 0) cout << " "; } } } return 0; }