def solve_c():
  n = int(input())
  for _ in range(n):
     c()

def c():
  n, m = [int(x) for x in input().split()]
  if m == 0:
    print(0)
    return 
  if m == 1:
    print(2*n-2)
  else:
    print(n*(n+1)//2+m-n)

solve_c()