#include
using namespace std;
const int MAX=32769;
int gcd(int a,int b)
{
int c;
while(b)
{
c=a%b;
a=b;
b=c;
}
return a;
}
int hash[MAX];
int main(void)
{
int n,num;
cin>>n;
while(n--)
{
int count=0;
cin>>num;
memset(hash,0,sizeof(hash));
for(int i=2;i