#include using namespace std; #define rep(i,n) for (int i = 0; i < (int)(n); ++i) #define rrep(i,n) for (int i = (int)(n-1); i >= 0; --i) #define Rep(i,a,b) for (int i = a; i < b; ++i) #define rRep(i,a,b) for (int i = a; i > b; --i) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define Bit(x,i) (((x)>>(i))&1) using ll = long long; using vi = vector; using vll = vector; using vvi = vector; using vvll = vector; using vb = vector; using vs = vector; using pii = pair; using pll = pair; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> p; // 2^(p-1) == 1 mod p // (2^(p-1))^n == 1 mod p (p>=3) // 2^x = 2^(x - n(p-1)) 2^(n(p-1)) == 2^(x - n(p-1)) mod p // (p-1)^2 = p(p-2) + 1 // n = p-1, x = (p-1)^2 => 2^((p-1)^2 - (p-1)^2) == (p-1)^2 mod p cout << 2 + ((p-1)*(p-1)-2)*(p>=3) << endl; } int main() { int T; cin >> T; while(T--) solve(); }