#include using namespace std; #define ll long long int largestPF(ll n) { if(n <= 1) return 0; int res = 0; while(n%2==0){ res=2; n/=2; } for(ll i=3; i*i<=n; i+=2){ while(n%i==0){ res=i; n/=i; } } if(n>1) res = n; return res; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int t; cin>>t; while(t--){ ll n,k; cin>>n>>k; if(n==k){ cout<<"-1\n"; continue; } bool ok = false; for(ll x=n; x>=max(2LL,n-100000); x--){ if(largestPF(x) > k){ cout<