#include #include using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 2000000001 int64_t mod_log(int64_t a, int64_t b, int64_t p) { int64_t g = 1; for(int64_t i = p; i; i /= 2) (g *= a) %= p; g = __gcd(g, p); int64_t t = 1, c = 0; for(; t % g; c++) { if(t == b){ if(c!=0)return c; } (t *= a) %= p; } if(b % g) return -1; t /= g; b /= g; int64_t n = p / g, h = 0, gs = 1; for(; h * h < n; h++) (gs *= a) %= n; unordered_map< int64_t, int64_t > bs; for(int64_t s = 0, e = b; s < h; bs[e] = ++s) { (e *= a) %= n; } for(int64_t s = 0, e = t; s < n;) { (e *= gs) %= n; s += h; if(bs.count(e)){ if(c+s-bs[e]!=0)return c + s - bs[e]; } } return -1; } int main(){ int t; cin>>t; rep(_,t){ long long n; cin>>n; int ans = mod_log(2,1,2*n-1); if(ans==-1)ans = 2*n-1; cout<