#include #include using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) #define all(x) begin(x), end(x) template bool chmin(T& x, T y) { return x > y ? (x = y, true) : false; } template bool chmax(T& x, T y) { return x < y ? (x = y, true) : false; } // rho char f_buf[256]; vector factor(ll n) { string cmd = "factor " + to_string(n); FILE* p = popen(cmd.c_str(), "r"); assert(p); assert(fgets(f_buf, sizeof(f_buf), p)); pclose(p); vector v; stringstream ss(f_buf); ss.ignore(sizeof(f_buf), ':'); while (ss >> n) v.push_back(n); return v; } void solve() { ll l, r; cin >> l >> r; chmax(l, 315LL); rep(x, l, r + 1) { if (x % 2 == 0) continue; int flg = 0; for (int d : {3, 5, 7, 11, 13, 17, 19, 23}) { if (x % d == 0) { if (x % (d * d) == 0 && factor(x / (d * d)).size() == 2) { cout << x << '\n'; return; } flg = 1; break; } } if (!flg) { auto v = factor(x); if (v.size() == 4 && v[0] == v[1]) { cout << x << '\n'; return; } } } cout << "-1\n"; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); int t = 1; // cin >> t; while (t--) solve(); }