#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

const int NN = 110000;
typedef long long ll;
int n, m, t, l, r, q;
ll k;
ll ans, x, y;

int main(){
	scanf("%d", &t);

	while (t--){
		scanf("%lld%lld", &x, &y);
		
		ll ans = 0;
		for (ll b=2; b<=y; b++){
			if (b * b - 1 > x) break;
			
			ll a = b * b - 1;
			ll k = b - 1;
			ll tmp = min(x, a + k * (y - b));
			if (tmp % k != 0) tmp -= tmp % k; 
			ans += (tmp - a) / k + 1;
			//printf("%lld\n", ans);	 
		}

		printf("%lld\n", ans);
	}
	
	return 0;
}
 
