#include using namespace std; int T,N; long gcd(long a,long b){return b?gcd(b,a%b):a;} long L(long N) { if(!(N&N-1)) { if(N==1)return 1; else if(N==2)return 1; else if(N==4)return 2; else return N>>2; } long T=1; for(long i=2;i*i<=N;i++) { if(N%i==0) { long x=1; while(N%i==0) { N/=i; x*=i; } if(N>1)x=L(x); else { x=x/i*(i-1); } T=T/gcd(T,x)*x; } } if(N>1) { long x=N-1; T=T/gcd(T,x)*x; } return T; } long modpow(long a,long b,long M){return b?modpow(a*a%M,b/2,M)*(b%2?a:1)%M:1;} main() { cin>>T; for(int i=1;i<=T;i++) { cin>>N; if(N==1) { cout<<1<i&&modpow(2,i,N)==1)ans=i; if(i!=(N-1)/i&&ans>(N-1)/i&&modpow(2,(N-1)/i,N)==1)ans=(N-1)/i; } }*/ int X=ans=L(2*N-1); for(int i=1;i*i<=X;i++) { if(X%i==0) { if(ans>i&&modpow(2,i,2*N-1)==1)ans=i; if(i!=X/i&&ans>X/i&&modpow(2,X/i,2*N-1)==1)ans=X/i; } } cout<