from sys import stdin, stdout
import math

q = int(stdin.readline())
for x in range(q):
    n, m = [int(x) for x in stdin.readline().split()]
    if m == 0:
        print("0")
    else:
        sum1 = ((n-1)*n)/2
        print(int(sum1 + m))
    #1: m
    #2:
    #n: 1