#include<bits/stdc++.h>
using namespace std;
int s[10010], ls;
int main()
{
for(int i = 2;i <= 10000;i++)
{
bool f = 0;
for(int j = 2;j <= sqrt(i);j++)
{
if(i % j == 0)
{
f = 1;
break;
}
}
if(f == 0)
{
s[++ls] = i;
}
}
int n;
cin >> n;
while(n--)
{
int ans = 0;
ls = 1;
int a;
cin >> a;
while(a != 1)
{
if(a % s[ls] == 0)
{
a /= s[ls];
}
else
{
ans++;
ls++;
}
}
ans++;
if(ans == 2)
{
cout << 1 << endl;
}
else
{
cout << 0 << endl;
}
}
return 0;
}