import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.util.Scanner;
import java.io.PrintWriter;

public class azd {
    public static void solve(int testNumber, Scanner in, PrintWriter out) {
        int t = in.nextInt();
        while (t-- > 0) {
            int a = in.nextInt(), b = in.nextInt();
            if (b == 0) {
                out.println("0");
            } else {
                int res = (a * (a - 1)) / 2;
                out.println(res + b);
            }
        }
        out.close();
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        solve(0,in,out);
    }
}
