#include<iostream>
#include<algorithm>
#define re register
using namespace std;
inline int read(){
int x=0,y=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-') y=-y;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=x*10+ch-'0';
ch=getchar();
}
return x*y;
}
int T,n;
int main(){
T=read();
while(T--){
n=read();
int cnt=0;
while(n%2==0) n/=2;
while(n%3==0){
n/=3;
cnt++;
}
if(n!=1) puts("1");
else if(cnt>1) puts("1");
else puts("0");
}
return 0;
}
求优化方案