/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package lode; import java.util.*; /** * * @author kajanek6 */ public class Lode { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner citac=new Scanner(System.in); int cases=citac.nextInt(); int []pole=new int[100000]; while(cases>0) { int number=citac.nextInt(); int i=0; for(int k=0;k<100000;k++) { pole[k]=0; } while(number>0) { pole[i]=number%3; number=number/3; i++; } i--; for(;i>0;i--) { System.out.printf("%d ",pole[i]); } System.out.printf("%d\n",pole[i]); cases--; } } }