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).
from io import StringIO
from sys import stdin, stdout


inp_ints = map(int, stdin.read().split())
read_int = inp_ints.__next__

output = StringIO()


def f(max_a, max_b):
    # 1 <= x <= max_x
    # a // b = a % b
    
    # a // b = a / b - (a % b) / b
    # a / b - (a % b) / b == a % b
    # a == a % b * (b+1)
    # a / (b+1) == a % b
    # a :: (b+1)
    # a // (b+1) == a % b
    
    # k*(b+1) // b = k % b
    # k // b + k = k % b
    # if k >= b then k + positive > k % b
    # so k < b
    # k = k % b
    # k = k
    
    # (a, b) is special <==> a = (b+1)*k and k < b
    # a = (b+1)*k and k <= b-1
    # a = (b+1)*k and k <= b-1    =>    a <= (b+1)*(b-1) = b^2 - 1
    # a :: (b+1) and a <= min(b^2 - 1, max_a)
    
    # variants_n for b = min(b^2 - 1, max_a) // (b+1)
    # (b^2 - 1) // (b+1) = b - 1
    # max_a // (b+1)
    
    # b_q = max b: (b^2 - 1) < max_a
    # b^2 < max_a + 1
    # b^2 <= max_a
    b_q = floor_sqrt(max_a)
    
    # result = sum(b-1 for b in range(1, min(b_q, max_b)+1)) +
    #     + sum(max_a // (b+1) for b in range(b_q+1, max_b+1))
    b_n_fst = min(b_q, max_b)
    variants_n_fst = b_n_fst * (b_n_fst+1) // 2 + (-1)*b_n_fst
    if b_q >= max_b:
        variants_n_snd = 0
    else:
        # sqrt(max_a) < max_b
        variants_n_snd = p(max_a, max_b+2-1) - p(max_a, b_q+2-1)
    return variants_n_fst + variants_n_snd


def p(x, max_div):
    # p(x, max_div) = sum(x // d for d in range(1, max_div+1))
    if x == 0:
        return 0
    max_div = min(max_div, x)
    p_c = floor_sqrt(x)
    result, next_d = __p_fst_half(x, max_div, p_c)
    if next_d > max_div:
        return result
    
    min_div_res = x // max_div
    for div_res in range(min_div_res, x//p_c):
        if div_res == min_div_res:
            max_d = max_div
            min_d = 1
            while min_d != max_d:
                mid_d = (min_d + max_d) // 2
                if x // mid_d == min_div_res:
                    max_d = mid_d
                else:
                    min_d = mid_d + 1
            result += (max_div - min_d + 1) * min_div_res
            continue
        # n of d: x / d in [div_res, div_res+1)
        # n of d: x in d*[div_res, div_res+1)
        
        # n of d: x >= d * Q
        # n of d: x/Q >= d
        # n of d: d <= x/Q
        result += (x//div_res - x//(div_res+1)) * div_res
    
    return result


def __p_fst_half(x, max_div, fst_size):
    assert max_div <= x
    result = sum(x // d for d in range(1, min(max_div, fst_size)+1))
    d = fst_size + 1
    while x // d == x // fst_size and d <= max_div:
        result += x // d
        d += 1
    return result, d


def floor_sqrt(x):
    assert x >= 0
    min_sqrt = 0
    max_sqrt = max(x, 1)
    while min_sqrt != max_sqrt:
        mid_sqrt = (min_sqrt + max_sqrt + 1) // 2
        if mid_sqrt**2 <= x:
            min_sqrt = mid_sqrt
        else:
            max_sqrt = mid_sqrt - 1
    return min_sqrt


t_n = read_int()
for i_t in range(t_n):
    x, y = read_int(), read_int()
    result = f(x, y)
    output.write(str(result))
    output.write('\n')

stdout.write(output.getvalue())
