"""609C"""
# import math
# import sys
def main():
	# n ,m= map(int,input().split())
	# a = list(map(int,input().split()))
	n,m = map(int,input().split())
	ans = n*(n+1)
	ans = ans//2
	if n==m:
		print(ans)
	elif m==0:
		print(0)
	else:
		print(ans-(n-m))
		

	
	return


# main()
def test():
	t = int(input())
	while t:
		main()
		t-=1
test()
