A pair of positive integers (a,b)(a,b) is called special if ab=amodb\left\lfloor\frac{a}{b}\right\rfloor=a \bmod b. Here, ab\left\lfloor\frac{a}{b}\right\rfloor is the result of the integer division between aa and bb, while amodba \bmod b is its remainder.

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

Input

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

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

Output

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

Example

input

1
2
3
4
5
6
7
8
9
10
9
3 4
2 100
4 3
50 3
12 4
69 420
12345 6789
123456 789
12345678 9

output

1
2
3
4
5
6
7
8
9
1
0
2
3
5
141
53384
160909
36

Note

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

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

In the third test case, there are two special pairs: (3,2)(3,2) and (4,3)(4,3).

Idea

a=kb+ma=kb+m,有 k,mNk,m\in\mathbb N,且 k0,0m<bk\geq 0,0\leq m<b;那么 ab=k=m\left\lfloor\frac{a}{b}\right\rfloor=k=m,将 kkmm 代替,得到 a=(b+1)ma=(b+1)m;可以看到,m=0m=0 是不可行的。

首先枚举 bb,已知 1by1\leq b\leq y。当 bb 确定时,枚举 mm,可得 aa;已知 1ax1\leq a\leq x,故得到不等式组 1m<b1\leq m<b1(b+1)mx1\leq (b+1)m\leq x

显然,mm 的上限值为 min(xb+1,b1)\min\left(\left\lfloor\frac{x}{b+1}\right\rfloor,b-1\right)

综上所述,答案为 b=1ymin(xb+1,b1)\sum\limits_{b=1}^y\min\left(\left\lfloor\frac{x}{b+1}\right\rfloor,b-1\right)

xb+1b1\frac{x}{b+1}\le b-1,得到 bx+1b\ge\sqrt{x+1};可知 x+1\sqrt{x+1} 附近有 BB,是满足 xb+1b1\left\lfloor\frac{x}{b+1}\right\rfloor\le b-1 最小的 bb

$\begin{aligned}\text{answer}&=(0+1+2\cdots +B-2)+\left(\left\lfloor\frac{x}{B+1}\right\rfloor+\left\lfloor\frac{x}{B+2}\right\rfloor+\cdots+\left\lfloor\frac{x}{y+1}\right\rfloor\right)\\&=\sum\limits_{i=1}^{B-2}i+\sum\limits_{i=B+1}^{y+1}\left\lfloor\frac{x}{i}\right\rfloor\end{aligned}$

求等差数列和数论分块。

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/******************************************************************
Copyright: 11D_Beyonder All Rights Reserved
Author: 11D_Beyonder
Problem ID: CF1485C
Date: 2021 Feb. 28th
Description: Number Theory, Counting
*******************************************************************/
#include<cmath>
#include<iostream>
using namespace std;
typedef long long ll;
const int N=100005;
int _;
int main(){
for(cin>>_;_;_--){
ll x,y;
cin>>x>>y;
ll B=sqrt(x+1);
while(x/(B+1)>B-1){
//找到取x/(B+1)的临界值
B++;
}
ll ans=0;
if(B-1>y){
//全都取b-1
ans+=y*(y-1)/2;
}else{
ans+=(B-1)*(B-2)/2;
}
for(ll l=B+1,r;l<=y+1;l=r+1){
if(l>x){
//除数为0
break;
}
r=min(x/(x/l),y+1);
ans+=(x/l)*(r-l+1);
}
cout<<ans<<endl;
}
return 0;
}