#include "bits/stdc++.h" using namespace std; #define rt return #define FOR(i,j,k) for(int i=j; i<(int)k;++i) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define mt make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; vector sieve(int n){ vector f(n+1); for(int i=3; i<=n; i+=2) f[i] = 1; for(int i=3; i<=sqrt(n); i+=2) if(f[i]) for(int j=i*3; j<=n; j+=i) f[j] = 0; vector res{2}; for(int i=3; i<=n; i+=2) if(f[i]) res.push_back(i); return res; } typedef ll Num; bool isPrime(Num n){ if(n==1) return 0; for(Num i=2; i*i<=n; ++i) if(n%i==0) return 0; return 1; } map factorize(ll n){ map res; for(ll i=2; i*i<=n; ++i){ while(n%i==0){ n /= i; ++res[i]; } } if(n!=1) ++res[n]; return res; } ll L, H; #define LIM 1000 int main(){ auto ps = sieve(100000); ios::sync_with_stdio(0); cin.tie(0); while(cin >> L >> H){ pair ans(-1, -1); if(H - L <= LIM){ for(ll i = L; i <= H; ++i)if(!isPrime(i)){ for(ll j = 2; j*j <= i; ++j){ if(i%j == 0){ smax(ans, mp(j, i)); break; } } } } else{ rep(i, sz(ps)){ FOR(j, i, sz(ps)){ ll val = (ll)ps[i] * ps[j]; if(val <= H && val >= L)smax(ans, mp((ll)ps[i], val)); ll q = H / val; auto it = lower_bound(all(ps), q); if(*it*ps[i] * ps[j] > H && it != ps.begin())--it; ll val2 = *it*ps[i] * ps[j]; if(*it >= ps[j]) smax(ans, mp((ll)ps[i], val2)); if(val > H)break; } } } cout << ans.second << endl; } }