#include<bits/stdc++.h>
using namespace std;
int T;
int n,tmp;
bool prime(int x){
if(x==1){
return 0;
}
for(int i=2;i*i<=x;i++){
if(x%i==0){
return 0;
}
}
return 1;
}
int main(){
cin.tie(0)->sync_with_stdio(0);
cin>>T;
while(T--){
cin>>n;
if(prime(n)){
cout<<"0\n"; continue;
}
int tmp=1;
for(int i=2;i*i<=n;i++){
if(n%i==0){
tmp=i; break;
}
}
while(n%tmp==0){
n/=tmp;
}
if(prime(n)){
cout<<"1\n";
}
else{
cout<<"0\n";
}
}
return 0;
}