All Tracks Problem

Game
/
No tags
Problem
Editorial
Analytics

Abhishek is playing a game.The game is played on a rectangular grid consisting of N rows and M columns . Initially all the cells of the grid are uncoloured.

Abhishek's initial score is zero. At each turn , he chooses score cell that is yet not coloured and colors that cell. The score obtained in this step will be number of neighbouring coloured cells of the cell that Abhishek coloured in this step . The game will  end when all the cells are coloured .Finally total score obtained at the end of the game will be sum of score obtained in each turn.

Abhishek wants to know what maximum score he can get? Can you please help him in finding this out?

Note:-Two cells are neighbours of each other if they share a side between them.

** INPUT**

   The input will contain an Integer T denoting the no. of test cases . Each test case contain  dimension of grid M & N

**OUTPUT**

   Total sum

CONSTRAINT

0<T<10

0<M<1000

0<N<1000

SAMPLE INPUT
2

2 2

3 2
SAMPLE OUTPUT
4
7
Time Limit: 5.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

This Problem was Asked in

Initializing Code Editor...
Notifications
View All Notifications

?