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).
import sys
from sys import stdout
import bisect as bi
import math
from collections import defaultdict as dd
from types import GeneratorType
##import queue 
##from heapq import heapify, heappush, heappop
##import itertools
##import io
##import os
##import operator
##import random
##sys.setrecursionlimit(10**7)
input=sys.stdin.readline
##input = io.BytesIsoO(os.read(0, os.fstat(0).st_size)).readline
##fo=open("output2.txt","w")
##fi=open("input2.txt","w")
mo=10**9+7
MOD=998244353
def cin():return map(int,sin().split())
def ain():return list(map(int,sin().split()))
def sin():return input().strip()
def inin():return int(input())

##----------------------------------------------------------------------------------------------------------------------
##

for _ in range(inin()):
    a,b=cin()
    b=min(a-1,b)
    if(b<=1):print(0)
    else:
        sqra=min(int(math.sqrt(a-1)),b)
        ans=0
        for i in range(1,sqra+1):
            r=a//i
            if(a%r<r):
                r-=1
##            print(i,r,max(min((r-i),b-1),0))
            ans+=max(min((r-i),b-i),0)
        print(ans)
            
        
        

                
                
            
            
        
        
    





    
##-----------------------------------------------------------------------------------------------------------------------#
def msb(n):n|=n>>1;n|=n>>2;n|=n>>4;n|=n>>8;n|=n>>16;n|=n>>32;n|=n>>64;return n-(n>>1)
##2 ki power
def pref(a,n,f):
    pre=[0]*n
    if(f==0):         ##from beginning
        pre[0]=a[0]
        for i in range(1,n):
            pre[i]=a[i]+pre[i-1]
    else:              ##from end
        pre[-1]=a[-1]
        for i in range(n-2,-1,-1):
            pre[i]=pre[i+1]+a[i]
    return pre

# in given set of integers
def kadane(A):
    maxSoFar = maxEndingHere = start = end = beg = 0
    for i in range(len(A)):
        maxEndingHere = maxEndingHere + A[i]
        if maxEndingHere < 0:
            maxEndingHere = 0;beg = i + 1
        if maxSoFar < maxEndingHere:
            maxSoFar = maxEndingHere
            start = beg
            end = i
    return (maxSoFar,start,end)  #max subarray sum and its range 
def modFact(n, p):
    if(n<0):return 0
    if n >= p: return 0
    result = 1
    for i in range(1, n + 1):result = (result * i) % p
    return result
def ncr(n, r, p):
    if(n<r or n<0): return 0
    num = den = 1 
    for i in range(r): 
        num = (num * (n - i)) % p ;den = (den * (i + 1)) % p 
    return (num * pow(den,p - 2, p)) % p


##https://github.com/cheran-senthil/PyRival/blob/master/pyrival/misc/bootstrap.py
##write @bootstrap before recursive func
def bootstrap(f, stack=[]):   
    def wrappedfunc(*args, **kwargs):
        if stack:
            return f(*args, **kwargs)
        else:
            to = f(*args, **kwargs)
            while True:
                if type(to) is GeneratorType:
                    stack.append(to)
                    to = next(to)
                else:
                    stack.pop()
                    if not stack:
                        break
                    to = stack[-1].send(to)
            return to
 
    return wrappedfunc
