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;

typedef long long int ll;
#define int ll
#define fast(); ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define tests() int _t; cin>>_t; while(_t--)
#define test int t = 1;
#define tests int t; cin >> t;
#define endl '\n'
#define sz(x) ll((x).size())
#define F first
#define S second
#define mp make_pair
#define vi vector <ll>
#define vd vector<double>
#define vvi vector <vi>
#define pii pair<ll, ll>
#define vpii vector <pii>
#define pdi pair<double, ll>
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define all(x) x.begin(),x.end()
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fr(i,n) for(ll i = n-1; i >= 0; i--)

#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cerr<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbgp(x) { cout << #x << ": " << x.first << " , " << x.second << endl; }
#define dbgv(x) { cout<< #x << ": "; for(auto i : x) cout << i << ' '; cout << '\n'; }

int inf = 1e18 + 100;
int mod = 1e9 + 7;
double pi = 3.1415926;

int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); }
int fpow(int a, int b, int _mod = mod) { if (b == 0)return 1; int t = (fpow(a, b / 2, _mod)); if (b % 2 == 0)return (t * t) % _mod; else return ((a) * (t * t)) % _mod; }

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

void solve() {
    int x, y;
    cin >> x >> y;
    int b = 1;
    int res = 0;
    int yy = y;
    int e = -1, ee = 0;
    bool f = false;
    while (((x / (b + 1)) >= b - 1 || x / (b+1) == e) && b <= y) {
        if (!f && (x/(b+1)) == b-1) {
            f = true;
            e = x / (b + 1);
            //dbg(b);
        }
        res += (f ? e : b - 1);
        ee = x / (b + 1);
        b++;
        yy--;
    }
    if (b > y) {
        cout << res << endl;
        return;
    }
    if (e == -1) e = ee;
    //dbg(e);
    b = e + 1;
    vi bb(b - 1);
    int sum = 0;
    for (int i = 0; i <= b - 2; i++) {
        int k = x / (i + 1);
        bb[i] = (y - k - sum);
        sum = (y - k);
    }
    //dbgv(bb);
    for(int i = b - 2; i >= 0; i--) {
        if (yy < bb[i]) {
            res += i * yy;
            break;
        }
        else res += i * bb[i], yy -= bb[i];
    }
    cout << res << endl;
}

signed main()
{
    fast();
    tests
    while (t--) {
        solve();
    }
}