Limits 5s, 512 MB

SpongeBob recently got obsessed with his (not perfect) rectangular face and has started making rectangular M×NM \times N grid like pizzas for his customers. Yes, he sells pizzas nowadays. If anyone can tell him how many unique rectangles can be found in this M×NM \times N grid (rectangle's corners have to be any of the integer points within the grid), then SpongeBob will serve them that pizza for free!

Now you all know this brainless friend of SpongeBob, Patrick, who just forgot where he keeps his money, wants to have free pizzas from Sponge. Help Patrick to solve this challenge.


You will be given CC (1C1061 ≤ C ≤ 10^6), the number of pizzas Patrick wants to have followed by C lines.

Each line will contain two numbers: MM and NN (1M,N3×1031 ≤ M, N ≤ 3×10^3), the size of each pizza.


Print one line for each pizza containing the answer of the challange.


2 2
3 3
10 20

Explanation for the first case:

There are 9 orthogonal and 1 diagonal (red colored) rectangles.


Login to submit.


78% Solution Ratio
upobirEarliest, Apr '19
nusuBotFastest, 0.3s
clist.byLightest, 88 MB
mdvirusShortest, 715B
Toph uses cookies. By continuing you agree to our Cookie Policy.