#include <bits/stdc++.h>
using namespace std;
long long a[100000000]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101};
int main(){
long long n,e;
cin>>n;
for (int i=1;i<=n;i++) {
cin>>e;
int total=0;
for (int j=0;j<=25;j++) {
if (e%a[j]==0) {
total++;
}
}
if (total==2) {
cout<<1<<endl;
}else {
cout<<0<<endl;
}
}
return 0;
}