#include #include #include using namespace atcoder; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000000000000000 long long modlog(long long a,long long b,long long m){ long long sq; { long long ng = 0LL,ok = m; while(ok-ng>1){ long long mid = (ok+ng)/2; if(mid*mid>=m){ ok = mid; } else ng = mid; } sq = ok+1; } unordered_map mp; long long t = 1; rep(i,sq){ if(!mp.count(t)){ mp[t] = i; } t *= a; t %= m; } long long now = 1; rep(i,sq){ long long temp = b * inv_mod(now,m); temp %= m; if(mp.count(temp)){ return i*sq + mp[temp]; } now *= t; now %= m; } return -1; } int main(){ int t; cin>>t; rep(_,t){ long long n; cin>>n; long long m = 2*n-1; if(n==1)cout<<1<