#include #include #define chmin(x,y) (x) = min((x),(y)) #define chmax(x,y) (x) = max((x),(y)) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define vec vector #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define pb push_back #define eb emplace_back using namespace std; using namespace atcoder; using ll = long long; using ld = long double; const ll mod = 998244353; using mint = modint998244353; const vector dx = {1,0,-1,0}, dy = {0,1,0,-1}; // using Graph = vector>>; using Graph = vector>; vec> pf(ll X){ if(X == 1) return {make_pair(1LL,1)}; vec> res; for(ll i = 2; i * i <= X; i++) if(X % i == 0){ int e = 0; while(X % i == 0){ X /= i; e++; } res.eb(i,e); } if(X != 1) res.eb(X,1); return res; } vector> get_divisors( ll N, ll L, ll R, vector> PF ){ int K = (int)PF.size(); vec> res; bool have_N = 0; for(ll i = 1; i * i <= N; i++){ if(N % i != 0) continue; if(i * i != N && L <= (N/i) && (N/i) <= R){ int id = 0, x = N/i; rep(j,K){ auto[p,e] = PF[j]; int E = 0; while(x % p == 0){ x /= p; E++; } if(E == e) id |= (1< 0) res.eb(N/i,id); // if(N/i == N) have_N = 1; } if(L <= i && i <= R){ int id = 0, x = i; rep(j,K){ auto[p,e] = PF[j]; int E = 0; while(x % p == 0){ x /= p; E++; } if(E == e) id |= (1< 0 || have_N) res.eb(i,id); } if(have_N && res.size() >= 3) break; } return res; } int main(){ // input int T; cin >> T; while(T--){ ll N,L,R; cin >> N >> L >> R; auto PFN = pf(N); int K = PFN.size(); // for(auto[p,e]:PFN) // cerr << p << " " << e << endl; if(N == 1){ cout << -1 << endl; continue; } auto cand = get_divisors(N,L,R,PFN); // cerr << "DEBUG: " << (int)cand.size() << endl; // for(auto [d,id] : cand) // cerr << d << " " << id << endl; // if(cand[0].first == N){ // if(cand.size() >= 3) // cout << cand[0].first << " " << cand[1].first << " " << cand[2].first << endl; // else // cout << -1 << endl; // continue; // } // else if bool found = 0; for(auto[a,x] : cand){ for(auto[b,y] : cand){ if(b <= a) continue; for(auto[c,z] : cand){ if(c <= b) continue; if(((x|y)|z) == (1<