How many ways are there to place a black and a white knight on an N * M chessboard such that they do not attack each other?
A knight can move two squares horizontally and one square vertically, or two squares vertically and one square horizontally.
The knights have to be placed on different squares and the knights attack each other if one can reach the other in one move.
The first line contains the number of test cases T. Each of the next T lines contains two integers N and M, representing the dimensions of the board.
Output T lines, one for each test case, each containing the required answer for the corresponding test case.
3 2 2 2 3 4 5
12 26 312
1 <= T <= 10000 1 <= N,M <= 100000 time limit 1 sec
Shortest code which runs with specified time limit decides the winner
i ll leave two days time for more users to try from today