import java.util.*;
import java.io.*;

public class C {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-->0) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int ans = (n) * (n+1) / 2;
			ans = ans - (n - m);
			if(m == 0) {
				ans = 0;
			}
			System.out.println(ans);
		}
	}
}
