/* -*- coding: utf-8 -*- * * 3253.cc: No.3253 Banned Product - yukicoder */ #include #include using namespace std; /* constant */ /* typedef */ using ll = long long; /* global variables */ /* subroutines */ /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int n, k; scanf("%d%d", &n, &k); if (n > (ll)k * k) { printf("%d\n", n); continue; } int minn = max(2, n - 281); for (; n >= minn; n--) { bool ok = true; for (int p = 1; p <= k && p * p <= n; p++) if (n % p == 0) { int q = n / p; if (q <= k) { ok = false; break; } } if (ok) break; } printf("%d\n", (n >= minn) ? n : -1); } return 0; }