import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class A {
    final static FastReader scan = new FastReader();
    public static void main(String[] args)
    {

        int t = scan.nextInt();
        while (t-->0){

          int n = scan.nextInt();
          int m = scan.nextInt();


          int s = n*(n+1)/2-(n-m);

            System.out.println(m==0?"0":s);


        }

    }

    static int[] IntArrayIp(int n){
        int[] a = new int[n];
        for (int i=0;i<n;i++) {
            a[i] = scan.nextInt();
        }
        return a;

    }


    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}