Help me in solving NUMREC problem

My issue

I can not understand the current problem.

My code

/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-->0) {
		    int n = sc.nextInt();
		    int m = sc.nextInt();
		    
		}
	}
}

Learning course: Prepare for your DSA interviews
Problem Link: CodeChef: Practical coding for everyone

@elmar1989
Plzz refer my c++ code for the logic.

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    long long int n,m;
	    cin>>n>>m;
	    long long int n1=(n*(n+1))/2;
	    long long int m1=(m*(m+1))/2;
	    n1=n1*m1;
	    n1-=(n*m);
	    cout<<n1<<endl;
	}
	return 0;
}

Its totally maths .