EdoceRahs Triangle
Time Limit: 5 Seconds Memory Limit: 65536 KB
You probably know Edoce and Rahs, that two twin sisters from last year’s contest. They are playing a game together. Edoce draws a grid of arbitrary sizes and then Rahs computes the number of acute triangles that could be formed using points of the grid (In an acute triangle every angle is lower than 90 degree). For example, a 2 × 2 grid contains 8 acute triangles. Although they suck at card games, they are pretty good at geometry games. So they call the game ICPC (I Cant Play Cards). Can you compete with them? Write a program to compute the number of such triangles, given the grid’s size.
Input
The input contains several test cases.
In the first line of input comes T (0 < T < 32), the number of test cases.
Each test case is one line with two integer N and M (1 ≤ N,M ≤ 100) indicating the length of the each side of the grid.
Output
For each test print just one integer in one line, indicating the number of acute triangles.
Sample Input
2 1 1 2 2
Sample Output
0 8Submit
Source: 13th Iran Nationwide Internet Contest - UT