A competitive eater, Alice is scheduling some practices for an eating contest on a magical calendar. The calendar is unusual because a week contains not necessarily $7$ days!

In detail, she can choose any integer $k$ which satisfies $1 \leq k \leq r$, and set $k$ days as the number of days in a week.

Alice is going to paint some $n$ consecutive days on this calendar. On this calendar, dates are written from the left cell to the right cell in a week. If a date reaches the last day of a week, the next day's cell is the leftmost cell in the next (under) row.

She wants to make all of the painted cells to be connected by side. It means, that for any two painted cells there should exist at least one sequence of painted cells, started in one of these cells, and ended in another, such that any two consecutive cells in this sequence are connected by side.

Alice is considering the shape of the painted cells. Two shapes are the same if there exists a way to make them exactly overlapped using only parallel moves, parallel to the calendar's sides.

For example, in the picture, a week has $4$ days and Alice paints $5$ consecutive days. [1] and [2] are different shapes, but [1] and [3] are equal shapes. [Image] 

Alice wants to know how many possible shapes exists if she set how many days a week has and choose consecutive $n$ days and paints them in calendar started in one of the days of the week. As was said before, she considers only shapes, there all cells are connected by side.


-----Input-----

The input consists of multiple test cases. The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases. Next $t$ lines contain descriptions of test cases.

For each test case, the only line contains two integers $n$, $r$ ($1 \le n \le 10^9, 1 \le r \le 10^9$).


-----Output-----

For each test case, print a single integer  — the answer to the problem.

Please note, that the answer for some test cases won't fit into $32$-bit integer type, so you should use at least $64$-bit integer type in your programming language.


-----Example-----
Input
5
3 4
3 2
3 1
13 7
1010000 9999999

Output
4
3
1
28
510049495001



-----Note-----

In the first test case, Alice can set $1,2,3$ or $4$ days as the number of days in a week.

There are $6$ possible paintings shown in the picture, but there are only $4$ different shapes. So, the answer is $4$. Notice that the last example in the picture is an invalid painting because all cells are not connected by sides. [Image] 

In the last test case, be careful with the overflow issue, described in the output format.

Difficulty: interview

Starter code:

Solutions:
def solve():
    n, r = list(map(int, input().split()))
    k = min(r, n - 1)
    print(k * (k + 1) // 2 + (r >= n))


for i in range(int(input())):
    solve()


#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    t = I()
    for _ in range(t):
        n,r = LI()
        if r < n:
            print((r*(r+1))>>1)
        else:
            ans = (n*(n-1))>>1
            ans += 1
            print(ans)
    return

#Solve
def __starting_point():
    solve()

__starting_point()

q = int(input())
for _ in range(q):
    n,r = map(int,input().split())
    max_k = min(n-1,r)
    wyn = max_k*(max_k+1)//2
    if r >= n:
        wyn += 1
    print(wyn)

t=int(input())
for i in range(t):
    n,r=list(map(int,input().split()))
    if r>=n:
        ans=(n-1)*n//2+1
        print(ans)
    else:
        ans=r*(r+1)//2
        print(ans)


import sys
import random
from fractions import Fraction
from math import *
 
def input():
    return sys.stdin.readline().strip()
 
def iinput():
    return int(input())

def finput():
    return float(input())

def tinput():
    return input().split()

def linput():
    return list(input())
 
def rinput():
    return list(map(int, tinput()))

def fiinput():
    return list(map(float, tinput()))
 
def rlinput():
    return list(map(int, input().split()))
def trinput():
    return tuple(rinput())

def srlinput():
    return sorted(list(map(int, input().split())))

def NOYES(fl):
    if fl:
        print("NO")
    else:
        print("YES")
def YESNO(fl):
    if fl:
        print("YES")
    else:
        print("NO")
    
def main():  
    #n = iinput()
    #k = iinput() 
    #m = iinput() 
    #n = int(sys.stdin.readline().strip()) 
    #n, k = rinput()
    #n, m = rinput()
    #m, k = rinput()
    #n, k, m = rinput()
    #n, m, k = rinput()
    #k, n, m = rinput()
    #k, m, n = rinput() 
    #m, k, n = rinput()
    #m, n, k = rinput()
    #q = srlinput()
    #q = linput()
    n, r = rinput()
    print((r >= n) + min(n * (n - 1), r * (r + 1)) // 2)
            
    

for i in range(iinput()):
    main()


# import sys
# input=sys.stdin.readline


t=int(input())
for _ in range(t):
    n,r=list(map(int,input().split()))
    if r<n:
        print((r*(r+1))//2)
    else:
        print((n*(n-1))//2+1)

from sys import stdin, stdout
import math

t = int(stdin.readline())
for _ in range(t):
    n, r = list(map(int, stdin.readline().split()))
    cnt = 0
    if r < n:
        print(r*(r+1)//2)
    else:
        print(n*(n-1)//2+1)



mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    for _ in range(int(input())):
        N, r = list(map(int, input().split()))
        if r >= N:
            print(N * (N-1) // 2 + 1)
        else:
            print(r * (r+1) // 2)


def __starting_point():
    main()

__starting_point()

from math import *

def r1(t):
    return t(input())

def r2(t):
    return [t(i) for i in input().split()]

for _ in range(r1(int)):
    n, r = r2(int)
    if n > r:
        print(r*(r + 1) // 2)
    else:
        print(n * (n - 1) // 2 + 1)


for _ in range(int(input())):
    n, r = list(map(int, input().split()))
    x = min(n-1, r)
    p = 0
    if r >= n:
        p = 1
    print(x*(x+1)//2 + p)


read = lambda: map(int, input().split())
t = int(input())
for _ in range(t):
	n, r = read()
	x = min(n - 1, r)
	ans = x * (x + 1) // 2
	if r >= n: ans += 1
	print(ans)

#list(map(int,input().split()))
t=int(input())
for _ in range(t):
    n,r=list(map(int,input().split()))
    r=min(r,n)
    if(r==n):
        su=((r-1)*(r))//2
        su+=1
        print(su)
    else:
        print((r*(r+1))//2)
        
        
    
    
    


import sys
input=lambda: sys.stdin.readline().rstrip()
t=int(input())
for _ in range(t):
  n,r=map(int,input().split())
  if n>r:
    print(r*(r+1)//2)
  else:
    print(n*(n-1)//2+1)

def solve():
    ans = 0
    n, k = map(int, input().split())
    u = min(k, n - 1)
    ans += (1 + u) * u // 2
    if k > n - 1:
        ans += 1
    print(ans)

t = int(input())
for _ in range(t):
    solve()

def read_int():
    return int(input())


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


t = read_int()
for case_num in range(t):
    n, r = read_ints()
    r = min(r, n)
    l = min(r, n - 1)
    ans = l * (l + 1) // 2
    if r == n:
        ans += 1
    print(ans)


import sys
input = sys.stdin.readline

t=int(input())
for tests in range(t):
    n,r=list(map(int,input().split()))

    if r>=n:
        print((n-1)*n//2+1)
    else:
        print(r*(r+1)//2)
        

    


for _ in range(int(input())):
    n,r=map(int,input().split())
    if r>n:
        r=n
    ans=0
    if r==n:
        ans+=1
        r=n-1
    print(ans+((r*(r+1))//2))

t = int(input())

for case in range(t):
    n, r = list(map(int, input().split(' ')))

    if r >= n:
        print(((n - 1) * n) // 2 + 1)
    else:
        print(r * (r + 1) // 2)

import sys
input=sys.stdin.readline
t=int(input())
for i in range(t):
    n,r=map(int,input().split())
    if r<n:print((r*(r+1))//2)
    else:print((n*(n-1))//2+1)

t = int(input())
while t:
    n, r = list(map(int, input().split()))
    ans = 0
    if n <= r:
        ans += 1
    ans += min(n - 1, r) * (min(n - 1, r) + 1) // 2
    print(ans)
    t -= 1


import sys
input = sys.stdin.readline
for _ in range(int(input())):
  n, r = map(int, input().split())
  if r >= n:
    print(n * (n - 1) // 2 + 1)
  else:
    print(r * (r + 1) // 2)

t=int(input())
for _ in range(t):
  a,b=map(int,input().split())
  if a>b:
    print((b*(b+1))//2)
  else:
    print((a*(a-1))//2+1)

import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
  n,r = map(int,input().split())
  if r >= n:
    ans = 1
    r = n-1
  else:
    ans = 0
  ans += r*(r+1)//2
  print(ans)

import sys
lines = sys.stdin.readlines()
T = int(lines[0].strip())
# (N, K) = map(int, lines[0].strip().split(" "))
for t in range(T):
    (n,r) = map(int, lines[t+1].strip().split(" "))
    mini = min(n-1, r)
    res = mini * (mini+1)//2
    if n-1 < r: res += 1
    print(res)

import sys
input = sys.stdin.readline
for f in range(int(input())):
    n,r=map(int,input().split())
    if r<n:
        print((r*(r+1))//2)
    else:
        sol=((n-1)*n)//2
        sol+=1
        print(sol)