rt
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int T;
double k;
inline void cz(double &r){
double tmp=(int)r + 1;
r*=tmp;
return ;
}
inline bool ok(double x){
return (int)x==x;
}
inline void work(){
cin>>k;
double r=k+0.5;
int ans=0;
while(!ok(r)){
cz(r);
++ans;
if(ans>10000){
puts("NO!");
return ;
}
}
cout<<ans<<"\n";
return ;
}
signed main(){
cin>>T;
while(T--)work();
return 0;
}