#include #include using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define FAST_IO \ ios::sync_with_stdio(false); \ cin.tie(0); const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; vector getPrimes(int n) { vector isPrime(n + 1, true); isPrime[0] = isPrime[1] = false; for (int i = 2; i <= n; i ++) { if (isPrime[i]) { for (int j = i + i; j <= n; j += i) { isPrime[j] = false; } } } vector primes; for (int i = 3; i <= n; i ++) { if (isPrime[i]) { primes.push_back(i); } } return primes; } template T pow_mod(T A, T N, T M) { T res = 1 % M; A %= M; while (N) { if (N & 1) res = (res * A) % M; A = (A * A) % M; N >>= 1; } return res; } bool MillerRabin(long long N, vector A) { long long s = 0, d = N - 1; while (d % 2 == 0) { ++s; d >>= 1; } for (auto a : A) { if (N <= a) return true; long long t, x = pow_mod<__int128_t>(a, d, N); if (x != 1) { for (t = 0; t < s; ++t) { if (x == N - 1) break; x = __int128_t(x) * x % N; } if (t == s) return false; } } return true; } bool is_prime(long long N) { if (N <= 1) return false; if (N == 2) return true; if (N % 2 == 0) return false; if (N < 4759123141LL) return MillerRabin(N, {2, 7, 61}); else return MillerRabin(N, {2, 325, 9375, 28178, 450775, 9780504, 1795265022}); } int main() { FAST_IO i64 L, R; cin >> L >> R; auto primes = getPrimes(1000000); int m = primes.size(); for (int i = 0; i < m; i ++) { auto a = primes[i]; if (a * a * a * a >= R) break; for (int j = i + 1; j < m; j ++) { auto b = primes[j]; if (a * a * b * b >= R) break; auto x = a * a * b; auto y = (L + x - 1) / x; if (y >= 1e6) { for (i64 c = y; x * c <= R; c ++) { if (is_prime(c)) { cout << x * c << endl; return 0; } } } for (int k = j + 1; k < m; k ++) { auto c = primes[k]; auto x = a * a * b * c; if(L <= x && x <= R) { cout << x << endl; return 0; } } } } cout << -1 << endl; return 0; }