rt
#include<bits/stdc++.h>
using namespace std;
long long t,n,k,ans=0;
int main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin>>t;
while(t--){
cin>>n>>k;
if(k==0) cout<<1<<endl;
else{
long long ls=n/(k+1);
for(int i=ls+1;;i++)
if(n/i==k) ans++;
else break;
cout<<ans<<endl;
}
ans=0;
}
return 0;
}