a = int(input())
ans = list(map(int, ("0 " * a).split()))
for i in range(a):
    q, w = map(int, input().split())
    if w == 0:
        ans[i] = 0
    else:
        ans[i] = (q * (q - 1))//2 + w
 
print(*ans, sep='\n')