A pair of positive integers (a,b) is called special if ⌊ a/b ⌋ = a mod b. Here, ⌊ a/b ⌋ is the result of the integer division between a and b, while a mod b is its remainder.

You are given two integers x and y. Find the number of special pairs (a,b) such that 1≤ a ≤ x and 1 ≤ b ≤ y.

Input

The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases.

The only line of the description of each test case contains two integers x, y (1 ≤ x,y ≤ 10^9).

Output

For each test case print the answer on a single line.

Example

Input


9
3 4
2 100
4 3
50 3
12 4
69 420
12345 6789
123456 789
12345678 9


Output


1
0
2
3
5
141
53384
160909
36

Note

In the first test case, the only special pair is (3, 2).

In the second test case, there are no special pairs.

In the third test case, there are two special pairs: (3, 2) and (4, 3).
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vct vector
#define vi vct<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
///............x...........///
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)), (X).end())
#define ft cout << "for test" << endl;
#define read(v, a, n) for (int i = a; i < n; i++)cin >> v[i];
#define print(v) for (auto it : v){cout << it << ' ';cout << endl;}
#define PI acos(-1.0)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test, cs = 1;cin >> test;while (test--)
#define casep cout << "Case " << cs++ << ":"<<endl;
///................function.....................///
#define D(a) (double)(a)
#define sqr(a) (a * a)
#define siz(s) (int)(s.size())
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define Min(a) *min_element(all(a))
#define Max(a) *max_element(all(a))
#define mod 1000000007
///.........Graph.........///
int X[] = {1, -1, 0, 0};
int Y[] = {0, 0, 1, -1};
///........constant........///
const int N = 2e5 + 5;
ll ok(ll mid, ll x){
    if(mid*(mid-1)+mid-1<=x){
        ///cout<<mid<<" "<<mid*(mid-1)+mid-1<<endl;
        return 1;
    }
    return 0;
}
int main()
{
    FIO;
    t_c{
        ll x,y;
        cin>>x>>y;
        ll hi=y,lo=2;
        if(x<=lo){
            cout<<0<<endl;
            continue;
        }
        ll ans=0;
        while (lo<=hi)
        {
            ll mid = (hi+lo)/2;
            if(ok(mid,x)){
                lo=mid+1;
                ans=mid;
            }
            else hi=mid-1;
        }
        ll result=0;
        if(ans==0){
            for(ll i=max(y,2ll); i<=min(y,x-1); i++){
                ll tmp = x/(i+1);
                result += tmp;
            }
        }
        else{
            result = (ans*(ans-1))/2ll;
            y = min(y,x-1);
            ans++;
            while(ans<=y){
                hi = y,lo=ans;
                ll now = x/(ans+1),nxt;
                while (lo<=hi)
                {
                    ll mid = (lo+hi)/2;
                    ll mm = x/(mid+1);
                    if(mm==now){
                        nxt = mid;
                        lo = mid+1;
                    }
                    else hi=mid-1;
                }
                result += now*(nxt-ans+1);
                ans=nxt+1;
            }
        }
        cout<<result<<endl;
        
    }
}