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).
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))
    max_div = min(max_div, x)
    
    min_div_result_to_take = floor_sqrt(x)
    result = __p_brute(x, max_div, min_div_result_to_take)
    min_div_result_possible = x // max_div
    if min_div_result_possible >= min_div_result_to_take:
        return result
    
    # compute sum for min_div_result_possible
    # where d is the fst d gives same result
    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_result_possible:
            max_d = mid_d
        else:
            min_d = mid_d + 1
    result += (max_div - min_d + 1) * min_div_result_possible
    
    for div_res in range(min_div_result_possible+1, min_div_result_to_take):
        # 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_brute(x, max_div, min_res_to_take):
    max_div = min(max_div, x)
    
    result = 0
    for d in range(1, max_div+1):
        div_res = x // d
        if div_res < min_res_to_take:
            break
        result += div_res
    return result


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


def read_ints():
    return map(int, input().split())


t_n, = read_ints()
for i_t in range(t_n):
    x, y = read_ints()
    result = f(x, y)
    print(result)
